-
Notifications
You must be signed in to change notification settings - Fork 4
Function.formatDateTime
kodiakhq[bot] edited this page Oct 1, 2024
·
56 revisions
@sumup-oss/intl / formatDateTime
formatDateTime(
date
,locales
?,options
?):string
Formats a Date
with support for various
date
and time styles.
Parameter | Type |
---|---|
date |
Date |
locales ? |
string | string [] |
options ? |
DateTimeFormatOptions |
string
import { formatDateTime } from '@sumup-oss/intl';
formatDateTime(new Date(2000, 1, 1), 'de-DE'); // '1.2.2000'
formatDateTime(new Date(2000, 1, 1), ['ban', 'id']); // '1/2/2000'
formatDateTime(new Date(2000, 1, 1, 12, 30), 'en-GB', {
year: 'numeric',
month: 'short',
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
}); // 1 Feb 2000, 12:30
In runtimes that don't support the Intl.DateTimeFormat
API, the date is
formatted using the Date.toLocale(Date|Time)String
API.
In runtimes that don't support the dateStyle
and timeStyle
options, the
styles are approximated using fallback options.