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
Locale | Localized value |
---|---|
en-US | 2/15/2022 – 3/23/2025 |
fr-FR | 15/02/2022 – 23/03/2025 |
de-DE | 15.2.2022 – 23.3.2025 |
fi-FI | 15.2.2022 – 23.3.2025 |
sv-FI | 2022-02-15 ‒ 2025-03-23 |
ko-KR | 2022. 2. 15. ~ 2025. 3. 23. |
hi-IN | 15/2/2022 – 23/3/2025 |