intlc
intlc copied to clipboard
Date range type
Example which is different to manually formatting as start – end:
> new Intl.DateTimeFormat('en-US-u-ca-buddhist').formatRange(new Date('1'), new Date('2'))
'1/1/2544 – 2/1/2544 BE'
I haven't been able to find a more common locale that differs however.
I haven't been able to find a more common locale that differs however.
How about this?
const longFormat = new Intl.DateTimeFormat("en", { dateStyle: "long" });
longFormat.formatRange(new Date('2020-10-01Z'), new Date('2020-10-20Z'))
// => 'October 1 – 20, 2020'