在XSLT中转换时间字符串

blu*_*ray 2 xslt

如何转换时间字符串

20101115083000 +0200
Run Code Online (Sandbox Code Playgroud)

2010-11-15 08:30:00 +0200
Run Code Online (Sandbox Code Playgroud)

使用XSLT?

Pet*_*ter 10

我们使用模板:

<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>
Run Code Online (Sandbox Code Playgroud)

我们将这些模板称为:

<xsl:call-template name="format-date-time">
    <xsl:with-param name="date" select="./Startdate"/>
</xsl:call-template>
Run Code Online (Sandbox Code Playgroud)

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