How to convert date in "YYYY-MM-DDTHH:MM:SSZ" format to "yyyymmddhhmmss" format?
I'm trying to convert date - 2023-09-28T20:35:41Z to BST/GMT format. I tried with $ZDT($ZDTH("2023-09-28T20:35:41Z",-2),8,1) but it's giving the output as '19700101 01:33:43' and looks link the date format in $ZDTH specified is wrong. Any inputs or solution would be appreciated.
Comments
set time="2023-09-28T20:35:41Z"write$TRANSLATE(tine,"-:TZ")
20230928203541Thanks for the response Robert. But this wouldn't account for the 1 hour time diff during day light savings.
I'm trying to convert date - 2023-09-28T20:35:41Z to BST/GMT format.
Please note that BST and GMT are not "format" and (may) have different values.
From your answer to @Robert Cemper it seems you need to covert to BST value (not GMT) and to "yyyymmddhhmmss" format.
To answer your question, is BST your system local timezone?
Jumping off of the answer I have given here only earlier today and being in a country currently observing(?) BST, you'll want to use the following approach:
- Use $ZDATETIMEH with the dformat of 3 and tformat of 7 (Note for the tformat that it's expecting the input as UTC, which is what you have with your source timestamp)
- Use $ZDATETIME with the dformat of 8 and tformat of 1
- Realise quickly that the tformat includes separators between the date and time, and within the time itself, so wrap it all in $ZSTRIP to remove all punctuation and whitespace...
Basically this:
WRITE$ZSTRIP($ZDATETIME($ZDATETIMEH("2023-09-28T20:35:41Z",3,7),8,1),"*P")
Gives you this:.png)
And demonstrating this for a date that isn't affected by BST you'll note that the time stays the same as the input because BST isn't in effect in the winter, taking the timezone I'm in back to GMT:
.png)
I hope this helps!