Thursday, April 25, 2013

Examples of Date and Time Formatting

Example: Gregorian Calendar
The following examples show a selection of dates and times and the way they might be formatted. These examples assume the use of the Gregorian calendar as the default calendar.

Required Output
Expression
2002-12-31
format-date($d, "[Y0001]-[M01]-[D01]")
12-31-2002
format-date($d, "[M]-[D]-[Y]")
31-12-2002
format-date($d, "[D]-[M]-[Y]")
31 XII 2002
format-date($d, "[D1] [MI] [Y]")
31st December, 2002
format-date($d, "[D1o] [MNn], [Y]", "en", (), ())
31 DEC 2002
format-date($d, "[D01] [MN,*-3] [Y0001]", "en", (), ())
December 31, 2002
format-date($d, "[MNn] [D], [Y]", "en", (), ())
31 Dezember, 2002
format-date($d, "[D] [MNn], [Y]", "de", (), ())
Tisdag 31 December 2002
format-date($d, "[FNn] [D] [MNn] [Y]", "sv", (), ())
[2002-12-31]
format-date($d, "[[[Y0001]-[M01]-[D01]]]")
Two Thousand and Three
format-date($d, "[YWw]", "en", (), ())
einunddreißigste Dezember
format-date($d, "[Dwo] [MNn]", "de", (), ())
3:58 PM
format-time($t, "[h]:[m01] [PN]", "en", (), ())
3:58:45 pm
format-time($t, "[h]:[m01]:[s01] [Pn]", "en", (), ())
3:58:45 PM PDT
format-time($t, "[h]:[m01]:[s01] [PN] [ZN,*-3]", "en", (), ())
3:58:45 o'clock PM PDT
format-time($t, "[h]:[m01]:[s01] o'clock [PN] [ZN,*-3]", "en")
15:58
format-time($t,"[H01]:[m01]")
15:58:45.762
format-time($t,"[H01]:[m01]:[s01].[f001]")
15:58:45 GMT+02:00
format-time($t,"[H01]:[m01]:[s01] [z]", "en", (), ())
15.58 Uhr GMT+02:00
format-time($t,"[H01]:[m01] Uhr [z]", "de", (), ())
3.58pm on Tuesday, 31st December
format-dateTime($dt, "[h].[m01][Pn] on [FNn], [D1o] [MNn]")
12/31/2002 at 15:58:45
format-dateTime($dt, "[M01]/[D01]/[Y0001] at [H01]:[m01]:[s01]")

Example: Non-Gregorian Calendars
The following examples use calendars other than the Gregorian calendar.
These examples use non-Latin characters which might not display correctly in all browsers, depending on the system configuration.
Description
Request
Result
Islamic
format-date($d, "[D١] [Mn] [Y١]", "Islamic", "ar", "AH", ())
٢٦ ﺸﻭّﺍﻝ ١٤٢٣
Jewish (with Western numbering)
format-date($d, "[D] [Mn] [Y]", "he", "AM", ())
‏26 טבת 5763
Jewish (with traditional numbering)
format-date($d, "[Dאt] [Mn] [Yאt]", "he", "AM", ())
כ״ו טבת תשס״ג
Julian (Old Style)
format-date($d, "[D] [MNn] [Y]", "en", "OS", ())
18 December 2002
Thai
format-date($d, "[D๑] [Mn] [Y๑]", "th", "BE", ())
๓๑ ธันวาคม ๒๕๔๕

########

0 comments: