Monday, 14 June 2010

MarkLogic: XQuery: UNIX Timestamp to xs:dateTime Conversion

A hopefully useful note for anyone in the situation where they need to convert from UNIX time to an XML dateTime()

First, to get a timestamp:

Which should return something like:

In cq/DQ, declare the following function:

Which can be run like so:

And should give you:

The XQuery code was taken (and updated for 1.0-ml) from this module:

1 comment:

Luthra.Ankit said...

Thanks mate, it was helpful!