Date & Time

I have a XML doc with date/time attributes. This date/time is decript with the millisecond since 1970. How can I transform this date/time attribute (Integer value) to reading (HTML) string by example ‘21.Jan 2002’

If you know the algorithm for converting from “milliseconds since 1970” to “yyyy-mm-dd” format, then you can probably code that algorithm in XSLT. But it’s probably simpler here to use an extension function, that is, a function written in a different language. The precise way in which you do this varies from one XSLT processor to another. If you’re using MSXML3 you can easily call JavaScript routines, if you’re using Saxon or Xalan you can call methods in Java classes. Look in the documentation for your specific product.

By the way, if you have any influence over the design of the XML document, it’s probably best to encode date and time in ISO 8601 format (YYYY-MM-DDThh:mm:ss) as that’s what XML Schema supports. This means that future specifications like XQuery and XSLT 2.0 will provide date and time arithmetic functions, provided you use that format.

Mike Kay