簡體   English   中英

XSLT如何從00到23:00寫入時間

[英]XSLT how to write time from 00 to 23:00

這是我的行。 我有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中寫小時。

嘗試:

<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')"/>

或修改循環

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM