# format-dateTime

format-dateTime($value as xs:dateTime?, $picture as xs:string) → xs:string?

Formats a dateTime, using a format controlled by the picture string. The result is equivalent to the 5-argument form of the function, with the third, fourth, and fifth arguments set to an empty sequence.

Arguments
| $value | xs:dateTime? | The dateTime to be formatted
| $picture | xs:string | Picture showing how the dateTime is to be formatted
Result | xs:string?

format-dateTime($value as xs:dateTime?, $picture as xs:string, $language as xs:string?, $calendar as xs:string?, $place as xs:string?) → xs:string?

Formats a dateTime, using a format controlled by the picture string.

Arguments
| $value | xs:dateTime? | The dateTime to be formatted
| $picture | xs:string | Picture showing how the dateTime is to be formatted
| $language | xs:string? | The language for the output
| $calendar | xs:string? | The calendar for the output
| $place | xs:string? | The country or Olson timezone where the event took place
Result | xs:string?

Links to W3C specifications

Namespace: http://www.w3.org/2005/xpath-functions

Applies to: XPath 2.0, XSLT 2.0, XQuery 1.0 and later versions

XPath 2.0 Specification

XPath 3.0 Specification

Notes on the Saxon implementation

Formats a date, using a format controlled by the picture string. If no language is specified, the value is taken from the current Java locale. If the language (explicitly supplied or defaulted) is other than "en", the system tries to locate a class named `net.sf.saxon.number.Numberer_XX` where XX is the language; this class must provide methods to perform the localization.

If a calendar other than AD or ISO is specified, the result is prefixed "[Calendar: AD]" and is otherwise output as if the default calendar were used.

The country argument is currently used only when the format requests output of timezones by name (using `[ZN]`): for example with language="en", country="gb" and a date that falls in British Summer Time, +01:00 is output as "BST". This is problematic, because the information is not really available: the data type maintains only a time zone offset, and different countries (time zones) use different names for the same offset, at different times of year. If the value is a date or dateTime, and if the country argument is supplied, Saxon uses the Java database of time zones and daylight savings time (summer time) changeover dates to work out the most likely timezone applicable to the date in question.

If the timezone is formatted as [ZN,6] (specifically, with a minumum length of 6 or more) then the Olsen timezone name is output (again, this requires the country to be supplied). The Olsen timezone name generally takes the form `Continent/City`, for example "Europe/London" or "America/Los_Angeles". If the date/time is in daylight savings time for that timezone, an asterisk is appended to the Olsen timezone name.

When formatting times in the 12-hour clock, with language="en", the abbreviations "a.m." and "p.m." are used. These can be shortened to "am" and "pm" by giving a maximum width of 2 (`[PN,*-2]`). The US convention of denoting noon as "pm" and midnight as "am" is followed, unless the maximum width is 8 or more (`[PN,*-8]`) in which case these values are represented as "noon" and "midnight" respectively.

Next