Skip to main content
Version: 1.10.1

DateFormatOptions

Syntax

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

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.
  • atTime?: boolean
    • Specify use of the "DATE at TIME" format (default true).

Defaults

{
date: 'full',
context: 'middle-of-text',
atTime: true
}
  • 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));
Wednesday, Jun 27, 2018, 4:23 AM
opts = { skeleton: "GGGGyMMMd", alt: { era: "sensitive" } };
log(cldr.Calendars.formatDate({ date, zoneId }, opts));
Jun 27, 2018 Common Era
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));

opts = { datetime: "full", atTime: false };
log(cldr.Calendars.formatDate({ date, zoneId }, opts));
4:23:00 AM EDT
6/27/18
Wednesday, June 27, 30 Heisei at 4:23:00 AM Eastern Daylight Time
Wednesday, June 27, 2018, 4:23:00 AM Eastern Daylight Time
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, June 27, 2561 BE

References