1
我已經得到了我傳遞的日期值,格式爲YYYYMMDD最好的辦法1.0
模板的日期格式模板如下:
<xsl:template name="formatDate">
<xsl:param name="date" />
<xsl:variable name="year" select="substring($date, 1, 4)" />
<xsl:variable name="month" select="substring($date, 5, 2)" />
<xsl:variable name="day" select="substring($date, 7, 2)" />
<xsl:value-of select="concat($month, '/', $day, '/', $year)" />
</xsl:template>
這將返回字符串20131004作爲10/04/2013這是正確的。
但我需要做的是如果$月有一個前導零,將其刪除。例如,20130930將2013年9月30日,當我更喜歡9/30/2013。
什麼是最有效的方法呢?我可以做一個選擇/當我設置變量的值之前,但我試圖用xslt以正確的方式做到這一點(我仍然試圖進入它,它會來)。
感謝