UTCNOW() - What can we do with this?

aucforum
Participant V

Hmmm Somebody has sneaked in a new, exciting feature?

What can we do with this?

1 22 2,414
22 REPLIES 22

NOW() returns the current local time. UTCNOW() returns the current UTC time,

Local time is convenient because it displays time in the local timezone basis that most people use day to day.

However, local time introduces problems for application developers.

  1. If your app needs to work across time zones, local time is ambiguous. If a meeting is occurring at 2:00 PM in one timezone it is occurring at a different hour in the other time zones.
  2. If you are using local time to remember the order that events occur, then the fall daylight saving transition perturbs the time order. At the fall time transition local time goes backward an hour. This can result in duplicate event times or out of order event times.

One way of dealing with these problems is to record times in UTC. Having UTCNOW() enables that.

That is good background. I think you should have it included in the same help documentation too:

Also include Steveโ€™s UTC Link:

It will work correctly not just the the DateTime, but the Date and Time column data types as well record the current Date and Time according to UTC respectively?

@aucforum
You can use DATE(UTCNOW()) and TIME(UTCNOW()) as an expression

Thank you LeventK.

Very simple and most useful.


@LeventK wrote:

@aucforum
You can use DATE(UTCNOW()) 


Thank you, I was looking for it!

Hi @Phil. Does this mean that Appsheet returns the UTC time from an online source independent from the time set on the device? This was a discussion on a past project where it seemed the user could determine the time AS posted by adjusting time set on their device.
Thanks

Is it true, @Aleksi? The function just removes the timezone adjustment, does it not? Itโ€™s still subject to the phoneโ€™s clock. If the user has manually set the phoneโ€™s time, I would expect UTCNOW() to be affected by that.

Steve
Participant V

For those who donโ€™t know what UTC is:

@Gerald_Kariuki Yes thatโ€™s true.

My bad, I read the question too quickly. Yes itโ€™s filtering the timezone away from your deviceโ€™s time.

So technically, the Appsheet with its UTCNOW() Function is receiving the date time AND the timezone (in a mutually recognizable format) from the device?

(For the record, this topic is converging with a similar one here:

)

PS: I am just trying to understand the mechanisms behind it so I can feel confident its working consistently and accurately.

It means thisโ€ฆ
If you are using timezone +03 in your device and your time in that device is 06/15/2019 10:56AM, UTCNOW() will give you the result as 06/15/2019 07:56AM. If you change your time in your device, it will use that time when generating a DateTime value with this expression.

Thanks @Steve and @Aleksi for the clarification. If possible to get time from a device independent source, that would be great in preventing user manipulation of time data posted.
Thanks again guys

if you create an anction with this UTCNOW() and then trigger that action with the Data Change Workflow, it will read the Timestamp from the server. Then it doesnโ€™t matter what the date or time you have in your device.

Some things to keep in mind. The user could disconnect from the internet, and then the server date time will be when the record is pushedโ€ฆ Also keep in mind that both location and time can be โ€œfakedโ€ by end usersโ€ฆ

UTCNOW() used in a workflow rule cannot be faked by the enduser.

Thank you and the rest of the team for resolving this ambiguity.

UTCNOW() records the date time it was pushed/synced so if they were offline for two days and then synced that would all show 2 days after the device record creation? Correct?

When you say UTCNOW() used in a workflow rule, what do you want to say. sorry but im learning. How can i use UTCNOW() to verify that the user has not modified the time in the mobile?

Right, it it the time the workflow rule runs, but at least that cannot be compromised. Anything client side can be compromised.

Awesome, thanks for the clarification. Iโ€™ll for sure start leveraging it more!

Top Labels in this Space