intlc icon indicating copy to clipboard operation
intlc copied to clipboard

Date range type

Open samhh opened this issue 3 years ago • 1 comments

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.

samhh avatar Apr 11 '22 21:04 samhh

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'

OliverJAsh avatar Apr 12 '22 07:04 OliverJAsh