Hey,
I am currently having the following problem.
I let my participants choose a time to which they will receive a daily reminder. This time is then stored in a variable and the reminder is executed through a daily rule at the chosen time. As my MC server time is set to UTC Europe/London, it sends the reminder at the wrong time if the participant is in a different timezone. Hence, I need to change the selected time to UTC. I have tried to solve this problem by executing different javascript scripts.
With new Date():
var now = new Date();
var UTCTime = now.getTimezoneOffset();
var selectedTimeInUTC = UTCTime/60 + ‘$reminderReceiveTime’*1;
var x = { ‘reminderReceiveTime’ : selectedTimeInUTC};
x;
With new Date() and $system variables:
var now = new Date(’$systemYear’*1, ‘$systemMonth’*1-1, ‘$systemDayOfMonth’*1, ‘$systemHourOfDay’*1, ‘$systemMinuteOfHour’*1);
var UTCTime = now.getTimezoneOffset();
var selectedTimeInUTC = UTCTime/60 + ‘$reminderReceiveTime’*1;
var x = { ‘reminderReceiveTime’ : selectedTimeInUTC};
x;
With an API:
fetch(‘https://worldtimeapi.org/api/ip’).then(response => response.json()).then(data => {
var time = data.datetime;
var UTCTime = time.getTimezoneOffset();
var selectedTimeInUTC = UTCTime/60 + ‘$reminderReceiveTime’*1;
var x = { ‘reminderReceiveTime’ : selectedTimeInUTC};
x;
});
Unfortunately, none of these scripts is working. new Date() is giving me the UTC time instead of the local time, and the API call is not executed at all.
I’m sure there’s a simple solution to finding out the local time of a participant’s smartphone.
Thanks a lot in advance for taking the time to reply!