I have been trying to convert a given dateTime to epoch time and also a given epoch time to dateTime. I am quite new to xslt and have been struggling with this quite for som
If you are trying to do this in XSLT 1.0 on MSXML (I know the original asker is not):
Replace the '1970-01-02'
with whatever text node you want and this should work, as long as that node was a valid date time. If not, it's easy enough to write up another simple method to do that using DateTime.Parse/TryParse
. The output of this template (against any valid XML) would be 86400
. Note that it's best to define methods in a CDATA
node to avoid needing to escape quotes or angle brackets (this code doesn't happen to use any but might be extended to for some reason).