Timestamp returning wrong date

Timestamp returning wrong date
0

#1

Hi all, I’m currently working on my timestamp service and run into an issue with parsing unix timestamps. When I try to convert it to a natural language date it comes back wrong. e.g. 1450137600 should give me December 15th 2015 as specified in the example app, but instead gives me January 17th, 1970.

Code is here: https://glitch.com/edit/#!/timestamp-jsanderson?path=server.js:37:18

Note at present it doesn’t support natural language input, I’m planning to add that later.

Many thanks!


#2

You need to multiply the timestamp by 1000 because JS uses milliseconds instead of seconds.

From MDN:
Screenshot from 2017-09-06 00-48-48


#3

Figures it’d be something simple. Thankyou so much! Everything is working great now.