Current time compare is wrong.. bug?

Hey all

Wondering if someone had the same issue -
Comparing a database field for “Date” and variable Current Time doesn’t work properly.

When you create a conditional action (Happens “Sometimes”) and compare a stored date in the database to the Current Time, the result is false even when the date in both is the same!
Until a certain time in the day when it suddenly becomes true.

Is seems that the Current Time variable doesn’t relate to the user’s Timezone but to UTC stored in the database??

Hi @Vasily,
Never tested this, but if you compare a date, I assume you have in format “yyyy-MM-dd” while current time will be “yyyy-MM-ddTHH:mm…”.

I would assume that date field was stored as Date (But probably has some time in the backend) and therefore at some point condition is true.

I think this is something that Adalo team has to clarify, but I would suspect it works this way.

The storage in servers, could also be epoch unix timestamp, and comparison are not all one to one.

Hi @Vasily ,

Do you have examples ?

I usually have a number beside date time, just in case to compare.

Having a reference of start of today is a good idea or just INT() of it.

OK I finally pinpointed the issue.

The problem is that the “Current Time” variable is in UTC when you apply “No formatting”. However, as soon as you apply any formatting, it gets converted to the device’s timezone…

And since the conditional trigger compares dates based on the database format i.e. “No formatting”, the “Current Time” variable is always going to be in UTC. So basically there is no way I can properly compare dates in user’s timezone?

My end goal is to determine if the user’s date is now > than the stored date value in the collection, and trigger a custom action based on that, but if I have no way of actually storing the user’s date in the collection I don’t see how I can achieve this.

@Colin - I’m sure you’ll say it’s by design but it feels more like a bug

I made an example for you.

Date Time is a number with lots of fraction digits.

The content is start of today as reference and 1 day ago, then the difference would be just 1, integer value means days, fraction means less than a day.

If let’s say the date time 2 is subtracted by 0.5, it means 12 hours

Thanks Yongki.
I’m trying to understand how this could help me.
In your example, the date and times are still based on UTC right?
The challenge is - how do you store and do calculations based on user’s local time?
I need to know if “today” for user is before another stored date/time. But there doesn’t seem to be a way to store “today” that is based on the user’s timezone, it will always be stored as UTC which may end up being a day earlier or a day later in user’s timezone.

1 Like

You can check the example here,

Date stored in collection will be in UTC as shown in “No Formatting”, otherwise it will be converted to user’s timezone.

Screen Shot 2022-06-22 at 3.45.17 PM

If I create new project with this action button and select both start date and end date to be today, there will be 2 additional actions after update form action that update start date time and end date time marking them as today, as explained in that post.

We can use this start date time and end date time to check any date time outside this range.

You can clone and change as you like.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.