Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xslt代码,以获得分钟过去_Xslt_Date_Time - Fatal编程技术网

Xslt代码,以获得分钟过去

Xslt代码,以获得分钟过去,xslt,date,time,Xslt,Date,Time,我从SQL中获取xml。xml有一个包含日期时间信息的节点。xml正在使用xslt进行转换。我需要计算xslt中过去的分钟数 例如,在xml中,我有以下节点: 2011-08-28322:11:52.383-07:00 我需要将当前时间作为参考,并计算从xml节点中的日期起经过了多少分钟。谢谢你的帮助 感谢这一转变: <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:

我从SQL中获取xml。xml有一个包含日期时间信息的节点。xml正在使用xslt进行转换。我需要计算xslt中过去的分钟数

例如,在xml中,我有以下节点:

2011-08-28322:11:52.383-07:00

我需要将当前时间作为参考,并计算从xml节点中的日期起经过了多少分钟。谢谢你的帮助


感谢这一转变

<xsl:stylesheet version="2.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:xs="http://www.w3.org/2001/XMLSchema">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>

 <xsl:template match="/">
   Current time: <xsl:sequence select="current-dateTime()"/>

   Elapsed minutes since: <xsl:sequence select="string(/)"/>:

   <xsl:sequence select=
   "(current-dateTime() - xs:dateTime(/) )
    div
     xs:dayTimeDuration('PT1M')
     "/>

 </xsl:template>
</xsl:stylesheet>
<t>2011-08-28T22:11:52.383-07:00</t>
   Current time: 2011-08-29T21:28:27.153-07:00

   Elapsed minutes since: 2011-08-28T22:11:52.383-07:00:

   1396.5795
说明:经过的分钟数计算为两个持续时间的划分结果:

  • 现在与指定日期时间之间的时差,以及
  • 正好一分钟的
    xs:dayTimeDuration

  • 您使用的是XSLT1.0还是2.0?好问题,+1。请参阅我的答案,以获得一个完整、简短且简单的解决方案。对不起,Dimitre,几天以来没有登录到stackoverflow。看起来不错,标记为答案,谢谢