0
const a = new Date("January 1, 2019").getTime(); // 1546329600000
const b = new Date("2019-01-01").getTime(); // 1546300800000

It seems that a produces a UNIX millisecond timestamp in my local time (PST) and b gives me a UTC timestamp. Tested in Google Chrome 76.

Why?

dmitrizzle
  • 774
  • 6
  • 15
  • Just to be clear, this is JavaScript ran through Google Chrome client browser. – dmitrizzle Sep 13 '19 at 17:35
  • "*It seems that `a` produces a UNIX millisecond timestamp in my local time (PST) and `b` gives me a UTC timestamp.*" all Unix timestamps are in UTC. Seems that `new Date` actually gives you different results in regards to timezones – VLAZ Sep 13 '19 at 17:41
  • 1
    Parsing of the first string is implementation dependent, likely it's treated as local. The second string is parsed as UTC, per ECMA-262. Both time values are UTC. – RobG Sep 13 '19 at 20:28

0 Answers0