Skip to main content
Version: 1.2.10

DateFormatOptions

Syntax

object {
  datetime?,
  date?,
  time?,
  skeleton?,
  wrap?,
  ca?,
  nu?,
  context?,
  alt?
}

Properties

  • datetime?: FormatWidthType
    • Format the date + time, using the format of the given width.
  • date?: FormatWidthType
    • Format the date only, using the format of the given width.
  • time?: FormatWidthType
    • Format the time only, using the format of the given width.
  • skeleton?: string (DateSkeleton))
    • Format using a flexible skeleton that defines which fields should appear in the date.
  • wrap?: FormatWidthType
    • Override the wrapper used to format date + time.
  • 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

{
date: 'full',
context: 'middle-of-text'
}
  • Numbering system default is determined by the locale.
  • Calendar system default is determined by the locale.

Example

let cldr = framework.get('en');
const date = 1530087780000;
const zoneId = 'America/New_York';
let opts: DateFormatOptions;

opts = { skeleton: 'yMMMEEEEdhm' };
log(cldr.Calendars.formatDate({ date, zoneId }, opts));

opts = { skeleton: 'GGGGyMMMd', alt: { era: 'sensitive' } };
log(cldr.Calendars.formatDate({ date, zoneId }, opts));

opts = { time: 'long' };
log(cldr.Calendars.formatDate({ date, zoneId }, opts));

opts = { date: 'short' };
log(cldr.Calendars.formatDate({ date, zoneId }, opts));

opts = { datetime: 'full', ca: 'japanese' };
log(cldr.Calendars.formatDate({ date, zoneId }, opts));

cldr = framework.get('ar');
opts = { datetime: 'full' };
log(cldr.Calendars.formatDate({ date, zoneId }, opts));

cldr = framework.get('en-u-ca-buddhist');
opts = { date: 'full' };
log(cldr.Calendars.formatDate({ date, zoneId }, opts));
Wednesday, Jun 27, 2018, 4:23 AM
Jun 27, 2018 Common Era
4:23:00 AM EDT
6/27/18
Wednesday, June 27, 30 Heisei at 4:23:00 AM Eastern Daylight Time
الأربعاء، ٢٧ يونيو ٢٠١٨ ٤:٢٣:٠٠ ص التوقيت الصيفي الشرقي لأمريكا الشمالية
Wednesday, June 27, 2561 BE

References