Reputation: 2575
I have a dateTime in this format: 2015-04-29T01:30:27.058Z and time difference of 5000milliseconds. Is there any XSLT function which can deduct this time difference and produce an output of a dateTime?
Upvotes: 0
Views: 710
Reputation: 167781
In XSLT 2.0 or later (requires an XSLT 2.0 processor like Saxon 9 or XmlPrime) you can use arithmetic with xs:dateTime
and xs:dayTimeDuration
, for instance
xs:dateTime('2015-04-29T01:30:27.058Z') + xs:dayTimeDuration('-PT0.058S')
computes a new xs:dateTime
2015-04-29T01:30:27Z
.
The XML schema namespace assumed for the prefix xs
is http://www.w3.org/2001/XMLSchema
.
See http://www.datypic.com/sc/xsd/t-xsd_dayTimeDuration.html on how dayTimeDuration
s can be written.
So with that version of the language my suggestion is to make use of those two data types and the arithmetic operations provided instead of going to milliseconds for computations.
Upvotes: 1
Reputation: 163675
In XSLT 2.0,
(xs:dateTime($timeStamp) - xs:dateTime('2000-01-01T00:00:00Z'))
div xs:dayTimeDuration('PT0.001S')
gives the number of milliseconds since the start of the current century.
Upvotes: 0