问题
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