1
我有这样的节点:转换时间戳更新与XSLT
<item id="37" publish_time="1293829200">
如何@publish_time转换迄今为止像DD.MM.YYYY?
我使用的libxslt
我有这样的节点:转换时间戳更新与XSLT
<item id="37" publish_time="1293829200">
如何@publish_time转换迄今为止像DD.MM.YYYY?
我使用的libxslt
下面是我写的秒转换为更可读的格式模板。你可以扩展它来掩盖你的需求:
<xsl:template name="convertSecsToTimeStamp">
<xsl:param name="seconds"/>
<xsl:variable name="hours" select="floor($seconds div (60 * 60))"/>
<xsl:variable name="divisor_for_minutes" select="$seconds mod (60 * 60)"/>
<xsl:variable name="minutes" select="floor($divisor_for_minutes div 60)"/>
<xsl:variable name="divisor_for_seconds" select="$divisor_for_minutes mod 60"/>
<xsl:variable name="secs" select="ceiling($divisor_for_seconds)"/>
<xsl:choose>
<xsl:when test="$hours < 10">
<xsl:text>0</xsl:text><xsl:value-of select="$hours"/><xsl:text>hh</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$hours"/><xsl:text>hh</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="$minutes < 10">
<xsl:text>0</xsl:text><xsl:value-of select="$minutes"/><xsl:text>mm</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$minutes"/><xsl:text>mm</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="$secs < 10">
<xsl:text>0</xsl:text><xsl:value-of select="$secs"/><xsl:text>ss</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$secs"/><xsl:text>ss</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
的
可能重复(http://stackoverflow.com/questions/5309370/how-to-format-date-in- [如何在XSLT 1.0日期格式] XSLT-1-0) –