Variable.formatDateTimeRange - sumup-oss/intl-js GitHub Wiki

@sumup-oss/intl / formatDateTimeRange

Variable: formatDateTimeRange()

const formatDateTimeRange: (startDate, endDate, locales?, options?) => string

Defined in: lib/date-time-format/index.ts:260

Formats a datetime range with support for various date and time styles.

Parameters

Parameter Type
startDate FormattableDateTime
endDate FormattableDateTime
locales? string | string[]
options? DateTimeFormatOptions

Returns

string

Example

import { formatDateTimeRange } from '@sumup-oss/intl';

const startDate = new Temporal.PlainDate(2000, 2, 1);
const endDate = new Temporal.PlainDate(2000, 2, 29);

formatDateTimeRange(startDate, endDate, 'de-DE');
// 01.–29.02.2000

Remarks

In runtimes that don't support the Intl.DateTimeFormat.formatRange API, the start and end dates are localized individually and joined using an en dash.