# DateTimeFormatOptions
Options to be passed into the constructor method.
NOTE
This is an abstract type. Any object of this structure can be used where this type is used.
# Properties
# dateStyle
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 as1/1/20
.'medium'
Outputs a string such asJan 1, 2020
.'long'
Outputs a string such asJanuary 1, 2020
.'full'
Outputs all components such asWednesday, 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
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
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
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
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
Number of millisecond digits to show. Valid values are 0-3.
Default: 0
# hour
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
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
Indicates how the hour should be formatted.
Can be set to one of the following:
'h11'
Outputs hour between0
and11
.'h12'
Outputs hour between1
and12
. (a.k.a.: 12-hour time)'h23'
Outputs hour between0
and23
. (a.k.a.: 24-hour time)'h24'
Outputs hour between1
and24
.
This option is ignored if the hour12
option has been set.
# localeMatcher
The locale matching algorithm to use.
Can be set to 'lookup'
or 'best fit'
.
This option is ignored on Android.
Default: best fit
# minute
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
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
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
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 as3:30 PM
.'medium'
Outputs a string such as3:30 PM
.'long'
Outputs a string such as3:30:32 PM
.'full'
Outputs all time components such as3: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
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
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
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
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.