Loading topic
Date holds no year, month, day, hour, or time zone. It holds one number: the count of milliseconds since midnight UTC on January 1, 1970, a moment called the Unix epoch. Every method on a Date reads or rewrites that number. Once you see a Date this way, most of its odd behavior ma4 min readDate holds a single number, the milliseconds since 1970-01-01T00:00:00Z. Every way of creating a Date is a way of working out that number.5 min readDate holds one millisecond time value, and new Date(year, monthIndex, day) uses zero-based months. Here you will learn which strings JavaScript 4 min readDate holds one number, the milliseconds since the Unix epoch, and how to create a Date from components or an ISO5 min readDate wraps a single millisecond time value, that months are zero-based, and that local and UTC getters and setters are two views of the same instant. Here we use that model to compare dates, avoid unwanted mutation, and add or subtract time without silent error3 min readDate stores one instant as milliseconds since the epoch. It also assumes you know the difference between local and UTC getters and setters, and how to copy a Date before changing it. Here those tools are applied to the cases where calendar time and elapsed tim4 min readDate wraps a millisecond time value, that ISO 8601 strings are the only reliably parsed format, and that local and UTC getters are two views of one instant. Here you will use those ideas to move dates between a program, a server, a database, and storage without4 min readIntl.DateTimeFormat, Intl.RelativeTimeFormat, Intl.PluralRules, and Intl.NumberFormat, is built the same way. You pass a list of locales and an options object. The engine works out what it can actually provide, and resolvedOptions() reports what it chose. On4 min readDate stores an instant as epoch milliseconds, and how local time and UTC give two views of that instant. It also assumes you have read the Intl basics: locale tags such as "en-US", the options object, and resolvedOptions(). Every example passes `timeZone: "U4 min readDate holds one instant as epoch milliseconds, the difference between local and UTC getters, and how to build an Intl.DateTimeFormat with dateStyle, timeStyle, and component options. Here you will add the timeZone option. It lets you show one ins4 min readIntl.DateTimeFormat works: locale tags, the dateStyle and timeStyle options, component options such as month: "long", and the timeZone option. It also assumes you know that a Date stores a single instant, and that local time and UTC are two ways 4 min readIntl.DateTimeFormat with dateStyle, timeStyle, component options, and the timeZone option, which the earlier chapters covered. It adds two tools to that formatter. formatToParts returns the localized output as typed pieces you can rearr4 min readIntl.RelativeTimeFormat produces these phrases in any supported locale. It handles word order, plural forms, and special words like "tomorrow" or the German "vorgestern" 5 min readIntl.PluralRules tells you which form a locale uses for a given number. You still supply the words; the API only picks the cate4 min readIntl.NumberFormat handles these values with the same locale rules that Intl.DateTimeFormat uses for dates.4 min readIntl.DateTimeFormat with dateStyle, timeStyle, and timeZone, and that you know the toLocale* shortcuts from earlier chapters. You should also be comfortable with Map and closures. It explains why creating a formatter costs more than using one4 min readDate stores a millisecond time value, how local and UTC getters differ, why daylight saving time (DST) breaks naive arithmetic, and how Intl.DateTimeFormat displays an instant in an IANA time zone. Here you wi4 min read