Intl.DateTimeFormat.prototype.formatRange
Formats a date range in the most concise way based on the locale and options set on the DateTimeFormat object
Syntax
dateTimeFormat.formatRange(startDate, endDate)Parameters
| Parameter | Type | Description |
|---|---|---|
| startDate | Date | number | The start date of the range |
| endDate | Date | number | The end date of the range |
Return Value
A string containing the formatted date range
Examples
const fmt = new Intl.DateTimeFormat('en-US', { dateStyle: 'medium' })
const start = new Date(2026, 2, 1)
const end = new Date(2026, 2, 15)
console.log(fmt.formatRange(start, end)) // 'Mar 1 – 15, 2026'const fmt = new Intl.DateTimeFormat('en-US', {
month: 'short',
day: 'numeric',
year: 'numeric'
})
const jan = new Date(2026, 0, 1)
const dec = new Date(2026, 11, 31)
console.log(fmt.formatRange(jan, dec))function formatEventRange(start: Date, end: Date, locale = 'en-US') {
const fmt = new Intl.DateTimeFormat(locale, {
dateStyle: 'long',
timeStyle: 'short'
})
return fmt.formatRange(start, end)
}Understanding Intl.DateTimeFormat.prototype.formatRange
The Intl.DateTimeFormat.prototype.formatRange method in JavaScript formats a date range in the most concise way based on the locale and options set on the DateTimeFormat object. It belongs to the Intl.DateTimeFormat object and is one of the most widely used methods for working with intl.datetimeformat values in modern JavaScript and TypeScript applications.
The method signature is dateTimeFormat.formatRange(startDate, endDate). It accepts 2 parameters: startDate, endDate. When called, it returns a string containing the formatted date range. Understanding when and how to use formatRange() helps you write more expressive, readable code.
Common use cases for Intl.DateTimeFormat.prototype.formatRange include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like intl-datetimeformat-format, intl-datetimeformat, intl-numberformat-formatrange, enabling you to chain operations together for complex data manipulation pipelines.
Supported in Chrome 76+, Firefox 91+, Safari 14.1+, Edge 79+.
Browser Compatibility
Supported in Chrome 76+, Firefox 91+, Safari 14.1+, Edge 79+.
Related Methods
Intl.DateTimeFormat.prototype.formatFormats a date according to the locale and formatting options of this Intl.DateTimeFormat object
Intl.DateTimeFormatCreates an Intl.DateTimeFormat object that enables language-sensitive date and time formatting
Intl.NumberFormat.prototype.formatRangeFormats a range of numbers according to the locale and formatting options of this Intl.NumberFormat object
More Intl.DateTimeFormat Methods
Other methods in the Intl.DateTimeFormat object
Related Tools
More Intl.DateTimeFormat Methods
Explore JavaScript Methods
Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.