如何使用XSLT将ticks转换成可读的datetime? [英] How to convert ticks into a readable datetime with XSLT?
本文介绍了如何使用XSLT将ticks转换成可读的datetime?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有这样的时间戳的XML:
I have an XML with timestamps like this:
<node stamp="1236888746689" />
我想在结果HTML中显示为时间的日期。
有没有办法使用XSLT(任何版本)?
And I would like to display them in the result HTML as date with time. Is there a way to do it with XSLT (any Version)?
编辑:
我正在使用XSLT2 .0与Saxon9。基数日期为1970-01-01 0:00。
I am using XSLT2.0 with Saxon9. The base date is 1970-01-01 0:00.
推荐答案
您的日期 1970- 01-01T00:00:00
并添加与邮票值一样多的毫秒:
You take the date 1970-01-01T00:00:00
and add as many milliseconds as the value of the stamp tells you:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.w3.org/TR/xhtml1/strict">
<xsl:template match="node">
<xsl:value-of
select='xs:dateTime("1970-01-01T00:00:00") + @stamp * xs:dayTimeDuration("PT0.001S")'/>
</xsl:template>
</xsl:stylesheet>
这篇关于如何使用XSLT将ticks转换成可读的datetime?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文