'Incorrect year after unix time convert
I have the following code. I'm trying to convert the unixtime to date format and i get a wrong year (Sun Mar 24 48447 18:26:27
) instead of 2016.
//obj.uploadDate = 1466679630387
var uploadDate = new Date(obj.uploadDate * 1000);
How can this issue be fixed?
Solution 1:[1]
In your obj.fileName
the timestamp is already in JavaScript timestamp (milliseconds) you don't need to multiply by 1000, just use
// obj.uploadDate = 1466679630387
var uploadDate = new Date(obj.uploadDate);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |