openmrs-esm-core

O3 Framework / formatDate

Function: formatDate()

formatDate(date, options?): string

Defined in: packages/framework/esm-utils/src/dates/date-util.ts:306

Formats the input date according to the current locale and the given options.

Default options:

If the date is today then “Today” is produced (in the locale language). This behavior can be disabled with noToday: true.

When time is included, it is appended with a comma and a space. This agrees with the output of Date.prototype.toLocaleString for most locales.

Parameters

date

Date

The date to format.

options?

Partial<FormatDateOptions>

Optional formatting options.

Returns

string

The formatted date string.