0

I'm retrieving a value which is supposed to be a epoch timestamp from a database and trying to convert it back to a date format to display it into a screen.

I can see that I'm retrieving the correct value i.e. 1644537600 which should represent Friday, 11 February 2022 00:00:00.

When I do the following var date = new Date(parseInt(timestamp)); I get Tue Jan 20 1970 01:48:57

I tried to divide timestamp / 1000 or 1000000 but I get the same result.

It could be with date formatting but struggling to make it work.

Butri
  • 339
  • 8
  • 22

1 Answers1

1

That epoch is in seconds, you need to multiply it by 1000.

MootezSaad
  • 76
  • 1
  • 2