UTCNOW() - What can we do with this?

Hmmm Somebody has sneaked in a new, exciting feature?

What can we do with this?

1 Like

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.

3 Likes

For those who don’t know what UTC is:

1 Like

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.

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

@Gerald_Kariuki Yes that’s true.

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.

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

1 Like

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.

1 Like

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…

2 Likes