Convert it to a numeric type instead of a string:
var date = new Date(parseInt(s, 10))
Explanation:
The input to the new Date()
constructor is a string. This means new Date()
will assume the input is "a ISO8601 string" instead of "Integer value representing the number of milliseconds", as described below.
According to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date it should be an integer if the value shall be interpreted as "representing the number of milliseconds since 1 January 1970 00:00:00 UTC (Unix Epoch)."
new Date()
has the following constructors (according to the link above):
new Date();
new Date(value);
new Date(dateString);
new Date(year, month, day, hour, minute, second, millisecond);
value (this is the constructor being used if you convert it to an integer value)
Integer value representing the number of milliseconds since 1 January 1970 00:00:00 UTC (Unix Epoch).
dateString (this was the constructor being called before)
String value representing a date. The string should be in a format recognized by the Date.parse() method (IETF-compliant RFC 2822 timestamps and also a version of ISO8601).