xslt date format change (dd-mmm-yyyy)

你说的曾经没有我的故事 提交于 2019-12-11 15:32:30

问题


I am using the below code to show the current date in xslt program.It's working fine With the date format yyyy-mm-dd. But i need the format dd-mmm-yyyy. Please help me to do this.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl" xmlns:cs="urn:cs"
>

          <xsl:value-of select="cs:datenow()"></xsl:value-of>

回答1:


You have tagged your question as XSLT 2.0 so I would expect you to simply get the current date with the current-date function http://www.w3.org/TR/xpath-functions/#func-current-date and to format it with the XSLT 2.0 function format-date http://www.w3.org/TR/xslt20/#format-date. So basically format-date(current-date(), '[D01]-[MN,*-3]-[Y0001]') gives a format like 11-JUL-2013. Depending on your needs (I am not sure what the format mmm stands for, as most date formatting routines define their own patterns) you need to adapt the "picture string" argument of format-date, see the documentation I linked to.



来源:https://stackoverflow.com/questions/17588060/xslt-date-format-change-dd-mmm-yyyy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!