Omri Omri - 1 year ago 87
Javascript Question

Issue with Unix time converting to date

I have the following code in Javascript:

//obj.uploadDate = 1466679630387
temp = new Date(obj.uploadDate);
uploadDate = temp.toString('yyyy-MM-dd HH:mm:ss');

For some reason, the value of
, instead of a formatted date.

What could be the issue?

Answer Source

Well, i had to convert to number, and now it's works great.

temp = new Date(Number(obj.uploadDate));
uploadDate =  temp.toString('yyyy-MM-dd HH:mm:ss');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download