在 XSLT 中转换时间字符串 [英] Convert time string in XSLT

查看:30
本文介绍了在 XSLT 中转换时间字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何转换时间字符串

20101115083000 +0200

2010-11-15 08:30:00 +0200

使用 XSLT?

推荐答案

我们使用模板:

<xsl:template name="format-date-time">
    <xsl:param name="date" select="'%Y-%m-%dT%H:%M:%S%z'"/>
    <xsl:value-of select="substring($date, 9, 2)"/>
    <xsl:text>/</xsl:text>
    <xsl:value-of select="substring($date, 6, 2)"/>
    <xsl:text>/</xsl:text>
    <xsl:value-of select="substring($date, 1, 4)"/>
    <xsl:text> </xsl:text>
    <xsl:value-of select="substring($date, 12, 2)"/>
    <xsl:text>:</xsl:text>
    <xsl:value-of select="substring($date, 15, 2)"/>
    <xsl:text>:</xsl:text>
    <xsl:value-of select="substring($date, 18, 2)"/>
</xsl:template>

我们这样称呼这些模板:

We call these templates like this:

<xsl:call-template name="format-date-time">
    <xsl:with-param name="date" select="./Startdate"/>
</xsl:call-template>

./Startdate 是一个 XML 日期,但使用子字符串技术,我认为您也可以解决您的问题.

./Startdate is an XML date, but with the substring technique, I think you could solve your problem too.

这篇关于在 XSLT 中转换时间字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆