new Date(milliseconds) returns Invalid date
You're not using a number, you're using a string that looks like a number. According to MDN, when you pass a string into Date
, it expects
a format recognized by the parse method (IETF-compliant RFC 2822 timestamps).
An example of such a string is "December 17, 1995 03:24:00
", but you're passing in a string that looks like "1372439683000
", which is not able to be parsed.
Convert Milliseconds
to a number using parseInt
, or a unary +
:
new Date(+Milliseconds);
new Date(parseInt(Milliseconds,10));
The Date
function is case-sensitive:
new Date(Milliseconds);