format
The format() function displays a TheDate using a custom format string and the chosen timezone.
Interactive example
Syntax
typescript
function format<
GenericInput extends TheDate,
GenericFormat extends string,
GenericTimezone extends Timezone
>(
formatString: GenericFormat,
timezone: GenericTimezone
): (input: GenericInput) => stringtypescript
function format<
GenericInput extends TheDate,
GenericFormat extends string,
GenericTimezone extends Timezone
>(
input: GenericInput,
formatString: GenericFormat,
timezone: GenericTimezone
): stringParameters
input:TheDatevalue (classic signature only).formatString: Format string.timezone: IANA timezone.
Return value
Formatted string based on the provided tokens.
Available tokens
YYYY: 4-digit yearYY: 2-digit yearMM: 2-digit monthDD: 2-digit dayHH: 2-digit hour (24h)mm: 2-digit minutesss: 2-digit secondsSSS: millisecondsZZ: timezone (IANA)
