How can I explain this timezone behavior of Date?

Viewed 33

For the JS Date object, ISO 8601 date strings that specify a time are treated as local (Note 2, here).

If we assume the locale for a machine is configured to be in England, and the current date in England is 23rd September 2022, the current local time zone (?) is UTC+0100 (British Summer Time).

If I supply a date without timezone that would in my locale ordinarily be in summertime (so in BST), then Date treats the string as BST (unsurprising).

If I supply a date without timezone that would, in my locale, ordinarily be outside of summertime (so in UTC), then Date treats the string as UTC (surprising, as UTC is not currently my local timezone).

new Date('2022-06-01T12:00:00') // Wed Jun 01 2022 12:00:00 GMT+0100 (British Summer Time)
new Date('2022-01-01T12:00:00') // Sat Jan 01 2022 12:00:00 GMT+0000 (Greenwich Mean Time) (! - my local timezone is BST, not GMT!)

How do I explain this? Is BST a time zone, or is it something else (eg. a mode of a timezone)?

2 Answers

The timezone BST/British Summer Time does not exit on Jan 1st. The areas that use BST on the summer use GMT during the winter.

For ISO 8601 date-times without a defined time zone, JavaScript does not assume the time zone to be the same as the time zone locally in effect, it assumes the local geographic location and then chooses the time zone that would be in effect at the specified wall-clock time in that location. Or something.

Related