使用XSLTxpath 2.0格式化时区。

问题描述 投票:0回答:1

我需要得到一个日期,格式是这样的。

2020-06-03T06:14:00.000+0100.

按照这个文档页[1],我尝试用这个表达式来做,但总是得到一个错误。

format-dateTime(current-dateTime(), "[Y0001]-[M01]-[D01]-[H01]:[m01]:[s][Z0000]")

我也试着用这个掩码放。

format-dateTime(current-dateTime(), "[Y0001]-[M01]-[D01]-[H01]:[m01]:[s][Z0001]")

但结果是2020-06-03-14:39:50+02:00。

我需要删除偏移量上的":",请问我可以使用哪种掩码?

[1]https:/tools.ietf.orghtmlrfc3339#section-5.6。

xslt-2.0 xpath-2.0
1个回答
0
投票

对于你的问题,一个变通的方法是将 format-dateTime 分成两个部分,并删除第二个表达式上的冒号。

concat(format-dateTime(current-dateTime(), "[Y0001]-[M01]-[D01]-[H01]:[m01]:[s]"),translate(format-dateTime(current-dateTime(), "[Z0001]"),":",""))

也许这对你有用

© www.soinside.com 2019 - 2024. All rights reserved.