Home > Back-end >  Converting epoch timestamp into a readable date
Converting epoch timestamp into a readable date

Time:02-12

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.

CodePudding user response:

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

  • Related