Hello — I'm using FreeMarker in a ClickDimensions template and I'm having some issues forcing datetimes to use the correct timezone. I have this at the top of my template:
<#setting time_zone="Canada/Pacific">
I've played around with that a little, setting it to different regions (e.g. "America/New_York") and it correctly adjusts the time when I call this:
${.now}
So that's great. However... I have a variable ('startdate') which holds a datetime value pulled from an instance of Microsoft Dynamics. For some reason it believes it's a Pacific datetime (the offset is -07:00) but it's not, it's UTC.
Here are some examples of what I've written:
${startdate}
${startdate?datetime("M/d/yyyy h:mm a")}
${startdate?datetime("M/d/yyyy h:mm a")?string.iso_m}
${startdate?datetime("M/d/yyyy h:mm a")?string.iso_m_nz}
${startdate?datetime("M/d/yyyy h:mm a")?string.iso_m_nz_u}
And this is what I receive:
- 5/23/2019 4:30 PM
- May 23, 2019 4:30:00 PM
- 2019-05-23T16:30-07:00
- 2019-05-23T16:30
- 2019-05-23T23:30
The third line reveals the problem — the datetime offset is incorrect. It should read +00:00 rather than -07:00.
How do I change the offset associated with a datetime...?