D. Caan
D. Caan

Reputation: 2019

XPath 1.0: Converting Timestrings

How can I convert Strings in this format dd/mm/yyyy hh:mm:ss into this format yyyy/mm/dd hh:mm:ss using XPAth 1.0?

Upvotes: 1

Views: 84

Answers (1)

dirkk
dirkk

Reputation: 6218

Unfortunately, XPath 1.0 does not even support regular expression. Hence, I think you are stuck with using substring functions.

The following is not very elegeant, but it should work ($date being your input string). It split the different parts and reconstruct the string afterwards.

concat(
  substring-after(substring-after(substring-before($date, ' '), '/'), '/'),
  '/',
  substring-before(substring-after(substring-before($date, ' '), '/'), '/'),
  '/',
  substring-before(substring-before($date, ' '), '/'),
  ' ',
  substring-after($date, ' ')
)

Upvotes: 2

Related Questions