formatDateTime
formatDateTime(
date: string | number | Date,
dateFormat: 'short' | 'medium' | 'long' | 'full',
timeFormat: 'short' | 'medium' | 'long',
options: DateFormatOptions,
): stringSource: date.ts:134
Formats a date and time together
Parameters
date(string | number | Date) — Date to formatdateFormat("short" | "medium" | "long" | "full", default: "'medium'") — Date format styletimeFormat("short" | "medium" | "long", default: "'short'") — Time format styleoptions(DateFormatOptions, default: "{}") — Additional options
Returns
string— Formatted datetime string
Example
CODE
formatDateTime(new Date(), 'short', 'short')
// '12/15/2024, 2:30 PM'