Change reminder time to UTC

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!

@Tobi Any chance you can have a quick look at this? There must be a very simple solution to this :thinking:

Dear @DomKuhn, we do not have a solution to this right now. One needs to implement a method in the ReactNative client of MobileCoach to get the local time zone of the user and store it in an MC variable. We are working on an intervention for the States with various time zones and may come back with a solution when we are finishing the prototype app.

Best, Tobi

Thanks for your reply Tobi!

I solved the problem by asking for the current time of the participant and calculating the difference between it and the server time. It’s not the ideal solution but works.

Best, Dominik