# DateTimeFormatOptions

Options to be passed into the constructor method.

Availability
9.1.0
6.0.0
9.2.0
Extends
Object

NOTE

This is an abstract type. Any object of this structure can be used where this type is used.

# Properties

# dateStyle

Availability
9.1.0
dateStyle :String

Specifies the locale's built-in month, day, and year formatting styles.

Can be set to one of the following:

  • 'short' Outputs a numeric string such as 1/1/20.
  • 'medium' Outputs a string such as Jan 1, 2020.
  • 'long' Outputs a string such as January 1, 2020.
  • 'full' Outputs all components such as Wednesday, January 1, 2020 AD.

This option is only supported on Android.

This option will be ignored if you assign other date related options such as month, day, year, etc.


# day

Availability
9.1.0
6.0.0
9.2.0
day :String

Indicates how the numeric day should be formatted.

Can be set to one of the following:

  • 'numeric' Outputs without a leading zero such as '1'.
  • '2-digit' Outputs to a 2 digit day such as '01'.

# dayPeriod

Availability
9.1.0
6.0.0
9.2.0
dayPeriod :String

Indicates how the AM/PM time component should be shown.

Can be set to one of the following:

  • 'narrow' Output the shortest AM/PM name.
  • 'short' Output a short AM/PM name.
  • 'long' Outputs the longest AM/PM name.

This option is only relevant in non-English languages where this component can have a much longer name.


# era

Availability
9.1.0
6.0.0
9.2.0
era :String

Indicates how the era name, such as AD or BC, should be shown.

Can be set to one of the following:

  • 'narrow' Outputs era such as 'A' for AD.
  • 'short' Outputs era such as 'AD'.
  • 'long' Outputs full era name such as 'Anno Domini' for AD.

# formatMatcher

Availability
6.0.0
9.2.0
formatMatcher :String

The format matching algorithm to use.

Can be set to 'basic' or 'best fit'. The 'basic' setting is documented here.

This option is ignored on Android.

Default: basic


# fractionalSecondDigits

Availability
9.1.0
fractionalSecondDigits :Number

Number of millisecond digits to show. Valid values are 0-3.

Default: 0


# hour

Availability
9.1.0
6.0.0
9.2.0
hour :String

Indicates how the hour should be formatted.

Can be set to one of the following:

  • 'numeric' Outputs without a leading zero such as '1'.
  • '2-digit' Outputs with a leading zero such as '01' when configured for 24-hour time. This setting is ignored when using 12-hour time.

# hour12

Availability
9.1.0
6.0.0
9.2.0
hour12 :Boolean

Indicates if formatter should output to either 12-hour or 24-hour time.

Set true to output to 12-hour time, which means the AM/PM dayPeriod option becomes applicable. Set false to output to 24-hour time.

By default, the formatter object will use the system's assigned time setting.


# hourCycle

Availability
9.1.0
6.0.0
9.2.0
hourCycle :String

Indicates how the hour should be formatted.

Can be set to one of the following:

  • 'h11' Outputs hour between 0 and 11.
  • 'h12' Outputs hour between 1 and 12. (a.k.a.: 12-hour time)
  • 'h23' Outputs hour between 0 and 23. (a.k.a.: 24-hour time)
  • 'h24' Outputs hour between 1 and 24.

This option is ignored if the hour12 option has been set.


# localeMatcher

Availability
6.0.0
9.2.0
localeMatcher :String

The locale matching algorithm to use.

Can be set to 'lookup' or 'best fit'.

This option is ignored on Android.

Default: best fit


# minute

Availability
9.1.0
6.0.0
9.2.0
minute :String

Indicates how minutes should be formatted.

Can be set to one of the following:

  • 'numeric' Outputs without a leading zero such as '1'.
  • '2-digit' Outputs with a leading zero such as '01'.

# month

Availability
9.1.0
6.0.0
9.2.0
month :String

Indicates how the month should be formatted.

Can be set to one of the following:

  • 'numeric' Outputs without a leading zero such as '3' for March.
  • '2-digit' Outputs a 2 digit month such as '03' for March.
  • 'narrow' Outputs a very short month name such as 'M' for March. (Android treats 'narrow' as 'short' instead.)
  • 'short' Outputs an abbreviated month name such as 'Mar' for March.
  • 'long' Outputs the full month name such as 'March'.

# second

Availability
9.1.0
6.0.0
9.2.0
second :String

Indicates how seconds should be formatted.

Can be set to one of the following:

  • 'numeric' Outputs without a leading zero such as '1'.
  • '2-digit' Outputs with a leading zero such as '01'.

# timeStyle

Availability
9.1.0
timeStyle :String

Specifies the locale's built-in hour, minute, and second formatting styles.

Can be set to one of the following:

  • 'short' Outputs a string such as 3:30 PM.
  • 'medium' Outputs a string such as 3:30 PM.
  • 'long' Outputs a string such as 3:30:32 PM.
  • 'full' Outputs all time components such as 3:30:32 PM PST.

This option is only supported on Android.

This option will be ignored if you assign other date related options such as hour, minute, second, etc.


# timeZone

Availability
9.1.0
6.0.0
9.2.0
timeZone :String

The time zone the Date object's value should be converted to when formatted.

Sets the time zone name to use. Can be set to 'UTC' to use Universal Time. Can also be set to a time zone name defined by the IANA time zone database such as 'America/New_York', 'Asia/Shanghai', etc.

By default, the formatter object will use the system assigned time zone.


# timeZoneName

Availability
9.1.0
6.0.0
9.2.0
timeZoneName :String

Indicates how the time zone should be shown.

Can be set to one of the following:

  • 'short' Outputs the GMT offset such as 'GMT-8' for US Pacific Time.
  • 'long' Outputs the full time zone name such as 'British Summer Time'.

# weekday

Availability
9.1.0
6.0.0
9.2.0
weekday :String

Indicates how a weekday name should be shown.

Can be set to one of the following:

  • 'narrow' Outputs weekday such as 'T' for Thursday.
  • 'short' Outputs weekday such as 'Thu' for Thursday.
  • 'long' Outputs weekday such as 'Thursday'.

# year

Availability
9.1.0
6.0.0
9.2.0
year :String

Indicates how the year should be formatted.

Can be set to one of the following:

  • 'numeric' Outputs to a 4 digit year such as '2020'.
  • '2-digit' Outputs to a 2 digit year such as '20' for the year 2020.