Date and time formatting

suggest change

Intl.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"

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents