Skip to main content
Version: 1.12.0

DateRawFormatOptions

Format a date directly using a raw format.

WARNING: For date formatting, consider this this only as last resort. Try formatDate with a skeleton.

Syntax

object {
  pattern,
  ca?,
  nu?,
  context?,
  alt?
}

Properties

  • pattern: string
    • A date time pattern string, specifying the fields to format
  • ca?: CalendarType
    • Override the calendar. The argument will be converted to the requested calendar before formatting.
  • nu?: NumberSystemType
    • Override the numbering system.
  • context?: ContextType
    • Specify the context in which the string will be display
  • alt?: DateFormatAltOptions
    • Specify options for alternate field values.

Defaults

{
pattern: '';
}
  • Numbering system default is determined by the locale.
  • Calendar system default is determined by the locale.

Example

const cldr = framework.get('en');
// June 27, 2018 4:23:00 AM
const date = 1530087780000;
const zoneId = 'America/New_York';

const s = cldr.Calendars.formatDateRaw(
{ date, zoneId },
{ pattern: 'EEE MMM y, d GGGG', alt: { era: 'sensitive' } }
);
log(s);
Wed Jun 2018, 27 Common Era

References