David Rodriguez
David Rodriguez

Reputation: 15

format timezone using XSLT/xpath 2.0

I need to get one date in one format like this:

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

following this documentation page [1], I tried to do with this expression, but always get an error:

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

I tried to put with this mask too:

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

but the result is 2020-06-03-14:39:50+02:00

I need to delete the ":" on the offset, ¿Which mask may I use?

[1]https://www.rfc-editor.org/rfc/rfc3339#section-5.6

Upvotes: 0

Views: 481

Answers (1)

zx485
zx485

Reputation: 29052

A workaround for your problem could be splitting the output of format-dateTime into two parts and remove the colon on the second expression:

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

Maybe this works for you.

Upvotes: 0

Related Questions