Standard built-ins

Intl.DateTimeFormat.prototype.formatRange()

Try the free JavaScript compiler

Format start and end instants using locale-specific range conventions; exact text depends on locale data.

Formal Syntax & Structure

javascript syntaxjavascript
formatter.formatRange(start, end)

Parameters & Attributes

NameTypeDescription
startDate | NumberStart instant.
endDate | NumberEnd instant.

Return Value

String

Localized range text.

Working Example

Example Snippetjavascript
const f=new Intl.DateTimeFormat("en-US",{timeZone:"UTC"});console.log(typeof f.formatRange(new Date(0),new Date(86400000)));
JavaScript Reference