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.

Date and time formatting specifiers and their meanings

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.

   

back to top