Custom Date Time Format with Time Zone
Is there a way to avoid interpretation of text in the custom date/time format?
I am following the Pyramid help reference for DateFormat, where it explains that the masking is based on Java specifications. When reading the Java specifications, they refer to using a single quote as an escape character to avoid intepretation.
I tried the following custom format in Pyramid:
YYYY-MM-DD HH:mm 'GMT'Z
However when I try this it still interprets the characters and displays the single quotes. (for example, it turns 'GMT' into 'G6T' because it interprets the M as month in year). I understand Pyramid may have a different way to handle escape characters, so I'm open to suggestions! I tried a few other common escape characters without any luck.
My goal is to indicate the time zone more clearly than the currently available "Z" mask allows (it only adds -XX:XX or -XXXX). So I'd like to end up with something like "2024-06-24 14:15 GMT-07:00".
4 replies
-
Hi ,
Where are you setting the format? Sorry, but from the small screen grab I can't tell the context in which you are working. Can you show the complete screen?
When I use 'GMT' in all the contexts I've tried it works fine (I don't have any DateTime data with TimeZones immediately to hand!):
LMK,
Ian
-
Hi , I'm not exactly using DateFormat, I'm actually within the Choose Date Format window for a dynamic text (Model Processed Date) within a publication. I've attached a screenshot to show more of the context, hope this helps. I referenced the help file for DateFormat, because I couldn't find anything for the custom formatting in the dynamic text properties window, but they seemed to have the same masking options. The main difference is DateFormat() supports wrapping your mask in quotes which makes it much closer to the Java examples in the links in the help file.
-
Hi
Use the backslash character "\" to escape the M thus:
yyyy-MM-dd hh:mm G\MT Z
Gives you:
Hope that helps!
Ian
-
Hi
That worked perfectly! I knew it was something about escaping, but I didn't think to individually escape the M. Great solution, thank you!