Skip to content

dateRange
@localizer/format 1.1.1

The dateRange is used to format date ranges in a human-readable way. It takes two dates as input and returns a string representation of the range, making it easier to display periods of time in your application.

Usage

typescript
import { 
dateRange
} from '@localizer/format';
const
rangeStart
= new
Date
(2022, 1, 15, 4, 20, 35);
const
rangeEnd
= new
Date
(2025, 2, 23, 12, 59, 0);
const
result
=
dateRange
(
rangeStart
,
rangeEnd
);

Formatter accepts JavaScript Date objects or numbers, which are treated as timestamps (milliseconds since January 1, 1970, 00:00:00 UTC).

Demo

LocaleLocalized value
en-US  American English2/15/2022 – 3/23/2025
fr-FR  French (France)15/02/2022 – 23/03/2025
de-DE  German (Germany)15.2.2022 – 23.3.2025
fi-FI  Finnish (Finland)15.2.2022 – 23.3.2025
sv-FI  Swedish (Finland)2022-02-15 ‒ 2025-03-23
ko-KR  Korean (South Korea)2022. 2. 15. ~ 2025. 3. 23.
hi-IN  Hindi (India)15/2/2022 – 23/3/2025

See also