0

In JavaScript, why does those two lines of code use different time zone?

new Date("09/12/2021 15:00:03 UTC")

Returns Sun Sep 12 2021 11:00:03 GMT-0400 (Eastern Daylight Time)

new Date()

Returns Sun Sep 12 2021 10:00:03 GMT-0500 (Eastern Standard Time)

Why are they not both on GMT-0500 (Eastern Standard Time)???

The lines are one after the other in code, so they are run by the same server.

Thanks.

-- EDIT --

I tried with ISO format and the timezone is still wrong.

new Date("2021-09-12T16:34:14.000Z")

And the output is Sun Sep 12 2021 12:34:14 GMT-0400 (Eastern Daylight Time)

LolCat
  • 539
  • 1
  • 11
  • 24

0 Answers0