R
fn

formatDate

testeddemo

Format a `Date` against a token string. Exposed for one-shot, non-reactive formatting; {@link useDateFormat} wraps this in a `computed`.

Demo

Loading demo…

Signature

ts
export function formatDate(
  date: Date,
  formatStr: string,
  options: UseDateFormatOptions ={ ... }

Parameters

ParameterTypeDescription
dateDateThe date to format
formatStrstringThe combination of tokens (e.g. `'YYYY-MM-DD HH:mm:ss'`)
options?UseDateFormatOptionsLocale and meridiem options

Returns

stringThe formatted string