Temporal shipped in Chrome 144 and hit TC39 Stage 4. Immutable types, real timezone support, and no more zero-indexed months. Here's why it finally replaces Date.
That’s what Unix time is… kind of. It’s what’s usually referred to as an “instant”, which is a moment in time that’s independent of any timezone or calendar. It’s just a plain number that increments by 1 every second.
A lot of systems already store dates and times as Unix timestamps, which means they’re already timezone-independent and the timezone and formatting are only applied when rendering it.
In some cases, you do actually need to know the timezone. Calendar events are a good example - an event may end in a different timezone than it starts in (like if the event involves travelling), so both timestamps need their own timezone.
There’s also cases where there’s no 1:1 mapping between a date/time and a Unix time. Daylight saving is the best example. When the clock moves forward from 2am to 3am, the times between 2am and 3am don’t have a Unix time, because they don’t actually exist. Conversely, when the clock moves from 2am back to 1am, the times between 1am and 2am have two Unix times - one before the change and one after the change.
That’s not to mention outliers like Antarctica where each research base chooses its own timezone.
That’s what Unix time is… kind of. It’s what’s usually referred to as an “instant”, which is a moment in time that’s independent of any timezone or calendar. It’s just a plain number that increments by 1 every second.
A lot of systems already store dates and times as Unix timestamps, which means they’re already timezone-independent and the timezone and formatting are only applied when rendering it.
In some cases, you do actually need to know the timezone. Calendar events are a good example - an event may end in a different timezone than it starts in (like if the event involves travelling), so both timestamps need their own timezone.
There’s also cases where there’s no 1:1 mapping between a date/time and a Unix time. Daylight saving is the best example. When the clock moves forward from 2am to 3am, the times between 2am and 3am don’t have a Unix time, because they don’t actually exist. Conversely, when the clock moves from 2am back to 1am, the times between 1am and 2am have two Unix times - one before the change and one after the change.
That’s not to mention outliers like Antarctica where each research base chooses its own timezone.
Dates and times are very complicated :)