3

Using AMPscript to try and allow our sales staff to enter items in UCT but have them display elsewhere in local time. I understand that the server uses CST which like UCT doesn't shift to or from Daylight savings. That said for the function I'm setting

SET @DateData = Field(@row, "DateTime")
SET @localDateData = SystemDateToLocalDate(@DateData)
SET @UCTConversion = DateAdd(@localDateData, "-8","H")

While this appears to set the time for now so it displays correctly what it's doing is allowing me to upsert a datetimestamp raw. So it's on the server like any other date time stamp and accurate only if we consider it to be in CST time. Then using the systemtolocal() function to process that system time to local time, then subtracting 8 hours is making the time appear on my EDT display to be the correct time.

If we want an event to begin at 9am here, we would enter it at 1p UTC. Since the "system" is using CST we need to account both for -6 hours offset from UTC and then adding another 2 for EST. I'm using system to local to avoid issues of Daylight savings but it's not responding when I change my system timezone.

I can add use dateadd to add the difference from CST to UCT on the upload and always correct for that with every edit or review of the record but that might be strange.

Note that when I used the script above it appeared correct at first, but when I used the control panel on my computer to change my time zone I was expected a change which didn't happen. So what is systemdatetolocaldate actually doing? Is it using IP time rather than a computers timezone setting? Any insights on this type of time conversion within ET will be useful.

1 Answer 1

3

I think the issue is that you are expecting the result to be the user machine's or browser system date. The SystemDatetoLocalDate() function is doing the following:

Converts a system datetime string or object to the user's local time.

It's the ExactTarget user setting for time zone, not your computer's time zone.

You would want to control the time zone based on the users location using something like javascript. Here is another StackOverflow question with more info.

2
  • Got it. We've used a javascript and the issues with that have been that {the one we tested} displays differently in different browsers. Was hoping something server side would help with that but I see now that the systemtolocal is not going to work in this context. As ET is a global platform I'm sure others would find this type of functionality useful. Really two functions, something that uses UTC as a server time for global coordination and something that translates that UTC to visitors local time (maybe using server side javascript?) to display that in their time.
    – Jonny Shaw
    Commented May 13, 2014 at 13:01
  • 1
    Feel free to add that as an idea in 3Sixty. Since AMPscript is more of a content scripting language, and not technically a server side language, not sure how it would fit. Most folk utilize their own server side coding languages to handle this sort of thing. Commented May 13, 2014 at 13:05

You must log in to answer this question.

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