Documentation

 

Date and time formatting

If activeLanguage = 'hu', then these translation texts:

// l10n.hu.json
{
  "default": "Alap: {{ 0 | datetime }}",
  "short": "Rövid: {{ 0 | D : dateStyle = short; timeStyle = short }}",
  "medium": "Közepes: {{ 0 | D : dateStyle = medium; timeStyle = medium }}",
  "long": "Hosszú: {{ 0 | D :dateStyle = long; timeStyle = long }}"
}

And this employ will produce the indicated output:

<ng-container *translate="let t; node: 'l10n'">
  <div>{{ t('default', Date.now()) }}</div>
  <div>{{ t('short', Date.now()) }}</div>
  <div>{{ t('medium', Date.now()) }}</div>
  <div>{{ t('long', Date.now()) }}</div>
</ng-container>
 
// HTML output
Alap: 2020. 01. 17.
Rövid: 2020. 01. 17. 21:35
Közepes: 2020. jan. 17. 21:35:34
Hosszú: 2020. január 17. 21:35:34 CET
 

Possible options:

dateStyle, ds
The date formatting style to use. Possible values include: "short", "medium", "long" and "full".
timeStyle, ts
The time formatting style to use. Possible values include: "short", "medium", "long" and "full".
localeMatcher, lm
The locale matching algorithm to use. Possible values are "lookup" and "best fit"; the default is "best fit".
timeZone, tz
The time zone to use. The only value implementations must recognize is "UTC"; the default is the runtime's default time zone. Implementations may also recognize the time zone names of the IANA time zone database, such as "Asia/Shanghai", "Asia/Kolkata", "America/New_York".
hour12, h12
Whether to use 12-hour time (as opposed to 24-hour time). Possible values are true and false; the default is locale dependent.
formatMatcher, fm
The format matching algorithm to use. Possible values are "basic" and "best fit"; the default is "best fit". See the following paragraphs for information about the use of this property.

The following properties describe the date-time components to use in formatted output, and their desired representations. Implementations are required to support at least the following subsets:

Implementations may support other subsets, and requests will be negotiated against all available subset-representation combinations to find the best match. Two algorithms are available for this negotiation and selected by the formatMatcher property: A fully specified "basic" algorithm and an implementation-dependent "best fit" algorithm.

weekday, wd
The representation of the weekday. Possible values are:
  • "long" (e.g. Thursday)
  • "short" (e.g. Thu)
  • "narrow" (e.g. T). Two weekdays may have the same narrow style for some locales (e.g. Tuesday's narrow style is also T).
era
The representation of the era. Possible values are:
  • "long" (e.g. Anno Domini)
  • "short" (e.g. AD)
  • "narrow" (e.g. A)
year, y
The representation of the year. Possible values are:
  • "numeric" (e.g. 2020)
  • "2-digit" (e.g. 20)
month, M
The representation of the month. Possible values are:
  • "numeric" (e.g. 2)
  • "2-digit" (e.g. 02)
  • "long" (e.g. March)
  • "short" (e.g. Mar)
  • "narrow" (e.g. M). Two months may have the same narrow style for some locales (e.g. May's narrow style is also M).
day, d
The representation of the day. Possible values are:
  • "numeric" (e.g. 1)
  • "2-digit" (e.g. 01)
hour, h
The representation of the hour. Possible values are "numeric", "2-digit".
minute, m
The representation of the minute. Possible values are "numeric", "2-digit".
second, s
The representation of the second. Possible values are "numeric", "2-digit".
timeZoneName, tzn
The representation of the time zone name. Possible values are:
  • "long" (e.g. British Summer Time)
  • "short" (e.g. GMT+1)