XML technologies / XSLT / Introduction to XSLT 2.0 / XSLT and XPath – round three / Date, duration and timestamp values / Formatting with format-date(), format-time(), format-dateTime()
(Excerpt from "XSLT 2.0 & XPath 2.0" by Frank Bongers, Chapter 3.)
In addition to the formatting string specifiers presented above, format-date(), format-time() and format-dateTime() provide a number of other shorthand specifiers for formatting their input values.
Figure: date and time formatting specifiers and their meanings.
For example, you can obtain the current calendar week from a date value as follows:
<p>Wir sind in Kalenderwoche <xsl:value-of select="format-date($heute,'[W01]')"/>.</p>
Code example: kap03/3.05/date.xsl (excerpt).
To obtain the weekday as plain text, use:
<p>Es ist ein <xsl:value-of select="format-date($heute,'[F]')"/>.</p>
Code example: kap03/3.05/date.xsl (excerpt).
The name of the weekday is output according to the system’s language setting, for example »Montag«, »Dienstag«, etc.
Copyright © Galileo Press, Bonn 2008
You may print the online version for your private use.
Otherwise, this chapter from "XSLT 2.0 & XPath 2.0 ― Das umfassende Handbuch" is subject to the same terms as the printed edition: the work and all its parts are protected by copyright. All rights are reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
Galileo Press, Rheinwerkallee 4, 53227 Bonn