Date and time formatting
suggest changeIntl.DateTimeFormat formats a date for a locale. A date-only ISO string such as "2016-07-21" is UTC midnight, so the local calendar day can be 20 July in timezones behind UTC.
const usDateTimeFormatting = new Intl.DateTimeFormat('en-US');
const esDateTimeFormatting = new Intl.DateTimeFormat('es-ES');
const usDate = usDateTimeFormatting.format(new Date('2016-07-21')); // "7/21/2016" in timezones where that UTC midnight is still 21 July
const esDate = esDateTimeFormatting.format(new Date('2016-07-21')); // "21/7/2016"
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents