且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

xslt 日期格式更改 (dd-mmm-yyyy)

更新时间:2023-02-26 20:12:47

您已将您的问题标记为 XSLT 2.0,因此我希望您只需使用 current-date 函数获取当前日期http://www.w3.org/TR/xpath-functions/#func-current-date 并使用 XSLT 2.0 函数 format-date http://www.w3.org/TR/xslt20/#format-date.所以基本上 format-date(current-date(), '[D01]-[MN,*-3]-[Y0001]') 给出了类似 11-JUL-2013代码>.根据您的需要(我不确定 mmm 的格式代表什么,因为大多数日期格式化例程定义了自己的模式)您需要调整 format-date 的图片字符串"参数,请参阅我链接到的文档.

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.