Intl.DateTimeFormat

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

JavaScript
dateTimeFormat.formatRange(startDate, endDate)

Parameters

ParameterTypeDescription
startDateDate | numberThe start date of the range
endDateDate | numberThe end date of the range

Return Value

A string containing the formatted date range

Examples

Basic Usage
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'
Practical Example
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))
Advanced Usage
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

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.