My app would be used by users from different countries and I would like to show the current time of a specific country, say, Italy UTC +1. How would I achieve this?
If you create a math column, give it a formula like ‘X’ and replace X with Now, it will show the current time respectively for each user based on the time on their device.
Or do you mean that you only want to show Italy time regardless of who is viewing your app?
Yes, you are right. Regardless of where users are from, they will only see the current time of Italy. Would you know how to do it?
The Format Date column with a ‘Z’ code will give you the UTC offset for the current user. Using that you can use the following math formula to calculate UTC time.
Now=Now
T=Offset
Now+((T*-1)/24)
But to get to an offset of +1, just add an addition of 1 to the formula.
Now+((T*-1+1)/24)
Hi Jeff, thank you for your solution. I think I understand what you are trying to do with Now+((T*-1+1)/24) … based on user’s respective current time find the UTC offset. But how exactly do I calculate user’s UTC offset as in T=Offset? and what did you mean by Format Date column with a Z code?
Hi Jeff, thank you for your solution and it works. I was skeptical at first as I wasn’t sure about the Format Z initially. Btw, since there is daylight saving now (hence UTC +2), I changed the formula to Now+((T*-1+2)/24).
I think I have a solution for the DST issue, so it will adjust automatically.
Create a javascript column and paste this code into it. This should determine the current offset for Italy factoring in whether it’s DST or not.
// Get the current date and time in the Rome timezone
let date = new Date();
let options = { timeZone: 'Europe/Rome', timeZoneName: 'short' };
let formatter = new Intl.DateTimeFormat('en-US', options);
let parts = formatter.formatToParts(date);
let offsetString = parts.find(part => part.type === 'timeZoneName').value;
// Extract numeric offset from the timezone name
let offset = parseInt(offsetString.match(/([+-]\d+)/)[0], 10);
return offset;
Then change your math column to this. D will equal the value returned from the javascript column.
Now+((T*-1+D)/24)
If you have access to the Call API action, a GET request to https://worldtimeapi.org/api/timezone/Europe/Rome would also provide a utc_offset.