使用 XSLT/xpath 2.0 格式化时区

format timezone using XSLT/xpath 2.0

我需要以一种格式获取一个日期:

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://www.rfc-editor.org/rfc/rfc3339#section-5.6

您的问题的解决方法是将 format-dateTime 的输出分成两部分并删除第二个表达式的冒号:

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

也许这对你有用。