format
import { format } from "https://esm.sh/v135/date-fns@3.6.0/index.d.mts";
@example
// Represent 11 February 2014 in middle-endian format:
const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
//=> '02/11/2014'
@example
// Represent 2 July 2014 in Esperanto:
import { eoLocale } from 'date-fns/locale/eo'
const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
locale: eoLocale
})
//=> '2-a de julio 2014'
@example
// Escape string by single quote characters:
const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
//=> "3 o'clock"
function format<DateType extends Date>(
date: DateType | number | string,
formatStr: string,
options?: FormatOptions,
): string;§
format<DateType extends Date>(date: DateType | number | string, formatStr: string, options?: FormatOptions): string
[src]§Parameters
§
options?: FormatOptions optional
[src]- An object with options