0

Same behavior on Chrome and Firefox running on Windows 10:

> new Date(1420088400000)
< Thu Jan 01 2015 00:00:00 GMT-0500 (Eastern Standard Time)

> new Date()
< Mon Aug 01 2022 21:27:35 GMT-0400 (Eastern Daylight Time)

> new Date().getTimezoneOffset()
< 240

Why is the millisecond overload of the Date() constructor returning standard time?

Michael Malak
  • 628
  • 8
  • 19
  • 1
    is one during daylight savings time, and the other not? the difference between daylight and standard time is that one is adjusted for daylight savings time. – dqhendricks Aug 02 '22 at 01:50
  • https://www.timeanddate.com/time/zone/usa/new-york?year=2015 – Phil Aug 02 '22 at 02:16
  • 1
    A timestamp represents milliseconds since midnight Jan 1st 1970 (UTC). The timestamp you're using represents 5am, Jan 1st 2015 (UTC). In your current locale (US Eastern Time), that was midnight Jan 1st, 2015. At that instant, it was standard time (not DST) – Phil Aug 02 '22 at 02:21
  • Phil -- thank you -- I believe that is the answer – Michael Malak Aug 02 '22 at 04:07

1 Answers1

0

First a small technicality: overloading does not exist in Javascript. But of course similar behavior can be achieved.

Then the answer is already given in the comments: your second Date is simply in daylight saving time, your first is not.

B M
  • 3,893
  • 3
  • 33
  • 47