XSLT如何写时间从00到23:00

时间:2013-08-19 14:14:59

标签: php html xslt

这是我的行。我有24行24小时。我在xslt中创建了一个循环。

<xsl:variable name="n-rows" select="24"/>

<xsl:template match="/">
  <html>
    <head>...</head>
    <body>
      <table>
        <tr>
          <xsl:call-template name="td-recursive"/>
        </tr>
      </table>
    </body>
  </html>
</xsl:template>

<xsl:template name="td-recursive">
  <xsl:param name="index" select="1"/>
  <td>
    <xsl:value-of select="$index"/>
  </td>
  <xsl:if test="$index &lt; $n-rows">
    <xsl:call-template name="td-recursive">
      <xsl:with-param name="index" select="$index + 1"/>
    </xsl:call-template>
  </xsl:if>
</xsl:template>

但是这里

<xsl:value-of select="$index"/>

我想写小时而不是00:00,01:00到23:00之间的数字

如何使用PHP在XSLT中编写小时。

1 个答案:

答案 0 :(得分:1)

尝试:

<xsl:value-of select="concat(format-number($index,'00'),':00')"/>

您的循环从1到24,如果您希望第一个小时为00:00而最后一个小时为23:00,您还需要减去1:

<xsl:value-of select="concat(format-number($index - 1,'00'),':00')"/>

或修改循环

相关问题