Users Current Time Zone

Hello,

Is it possible to determine the current time zone of the user and return the value into a table?

I tried to find the current time zone data in the CONTEXT options.

Thanks,

Alex

There’s no direct way to get it, but you can compute the time zone offset from UTC with:

(NOW() - UTCNOW())
2 Likes

Thanks Steve,

Below is my use case. I am trying to covert my ‘Task Start Time’ field to
Unix Time. If NOW () always gives me the current time for the user (based on
their time zone), is there a way to convert the formula below, to get the
UNIX equivalent of my ‘Task Start Time’?

(HOUR(DATE(NOW()) - “01/01/1970”))*3600 + (MOD(HOUR(NOW() -
“01/01/1970”),HOUR(DATE(NOW()) - “01/01/1970”)))*3600 +

MINUTE(NOW() - “01/01/1970”)*60 +

SECOND(NOW() - “01/01/1970”)

I tried to replace NOW() with DATETIME(‘Task Start Time’) but it did not
work

https://community.appsheet.com/t/is-it-possible-to-generate-a-unix-timestamp
-w/2337/2

TOTALSECONDS(UTCNOW() - "1/1/1970 00:00:00")
2 Likes

Perfect

Thank you Steve

1 Like

Related question. Is it possible to convert a date time field, that is not the current time, to Unix. In other words, if the ‘Task Start Time’ was entered as April 23, 6:00 AM and we need the equivalent Unix ‘Task Start Time’ instead of the current Unix Time

Maybe this:

TOTALSECONDS([Task Start Time] - "1/1/1970 00:00:00" + (NOW() - UTCNOW()))
1 Like

Hi Steve,

This worked perfectly.

Thanks,

Alex

2 Likes

Hi Steve,

Actually, for some reason the results are off by exactly 12 hours.

What is the time zone of the device performing the computation? Is it 12 hours off UTC?

The time zone of the device is (MST) UTC-7

The (NOW() - UTCNOW() portion of the formula seems to be doing the time zone
offset correctly.

UNIX Epoch is 1/1/1970 00:00:00.

Everything looks like it should work, even with Daylight Saving Time. But
for some reason, all the Unix results are exactly 12 hours greater than they
should be

1 Like

Where are you observing the incorrect value?

When I use the Test function in the Expression editor

1 Like

Hmm… It’s working fine for me. Is [Task Start Time] a DateTime value?

Yes. Correct, Task Start Time is a DateTime value

Should I try logging out of Appsheet and logging in again?

1 Like

You could, but I wouldn’t expect it to have any effect.

I’m kinda at a loss here. I think perhaps it’s time to engage support@appsheet.com for a deeper look.