1

I am trying to convert a timezone from CST to UTC using AMPscript

Example: Date & time in CST: 2021-02-22 5:01:01 PM

I wanted to convert this to UTC format, something like this below,

2021-02-22T12:01:01Z

Can someone help me with how to convert this using AMPscript?

Thanks & regards,

Siva

2 Answers 2

3

For completeness and future "lurkers" stumbling upon this question: AMPscript is written in C#. So, most, if not all, C# date format strings ought to work with Format().

2

CST is always 6 hours behind UTC - there is no impact of Daylight Savings, so I find the easiest way is to convert back to GMT and then force the formatting. This should do the job for you:

%%[
  SET @nowGMT = DateAdd(Now(), 6, "H")
  SET @formattedUTCDate = Format(@nowGMT, "yyyy-MM-ddTHH:mm:ssZ", "Date")
]%%
%%=v(@formattedUTCDate)=%%

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .