Welcome to date-hell: I need to parse a given date...
# lucee
m
Welcome to date-hell: I need to parse a given date/time string like this (
2023-05-01 01:03:14 (Europe/Berlin)
) to a valid date. But trying this in Lucee always results in an
Unparseable date
-error. Is there a simple way, or do I really need to split the string to make it a readable datetime-string for Lucee?
s
You could try dropping to Java's date functions for parsing it but it seems easier to just write a function that treats the whole thing as a space-delimited list and then wipe out the (Europe/Berlin) part which is likely what is causing the breakage. Lucee should be able to do yyyy-mm-dd hhnnss
q
Just to verify -- are you using LSParseDateTime(), or just ParseDateTime?
s
both will break on that
both will work if you drop the (europe/berlin)
you could try lsParseDatetime with the
format
argument
m
Tried LSParseDateTime(). I will drop the (europe/berlin).
Silly me, why didn't i ask Copilot when i already Pay for. Will try
💯 1
m
For fun here is what i wrote to take in the timezone string https://trycf.com/gist/51e3e05660e8e19a982d3c96cad7a233/lucee6-beta?theme=monokai It works in Lucee Adobe CFML doesn't have the ability to pass in a string for GetTimeZoneInfo
🙌 2
r
I believe valid format is 2023-12-31T235959+01:00 - but when timezone is set - "Europe/Berlin" to be used
m
@Michael Schmidt s solution works like a charm. Thanks for sharing.