# Current time compare is wrong.. bug?

**URL:** <https://forum.adalo.com/t/current-time-compare-is-wrong-bug/28454>\
**Category:** Get Help\
**Created:** [June 19, 2022, 11:44am UTC](https://forum.adalo.com/t/current-time-compare-is-wrong-bug/28454 "2022-06-19T11:44:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vasily](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/vasily/32/10710_2.png) [@Vasily](https://forum.adalo.com/u/Vasily)\
**Post date:** [June 19, 2022, 11:44am UTC](https://forum.adalo.com/t/current-time-compare-is-wrong-bug/28454/1 "2022-06-19T11:44:32Z")

</div>

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??

---

<div class="post-metadata">

**Author:** ![JL\_LJ](https://avatars.discourse-cdn.com/v4/letter/j/f08c70/32.png) [@JL\_LJ](https://forum.adalo.com/u/JL_LJ)\
**Post date:** [June 19, 2022, 7:56pm UTC](https://forum.adalo.com/t/current-time-compare-is-wrong-bug/28454/2 "2022-06-19T19:56:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Yongki](https://avatars.discourse-cdn.com/v4/letter/y/7c8e57/32.png) [@Yongki](https://forum.adalo.com/u/Yongki)\
**Post date:** [June 19, 2022, 8:53pm UTC](https://forum.adalo.com/t/current-time-compare-is-wrong-bug/28454/3 "2022-06-19T20:53:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Vasily](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/vasily/32/10710_2.png) [@Vasily](https://forum.adalo.com/u/Vasily)\
**Post date:** [June 20, 2022, 10:46pm UTC](https://forum.adalo.com/t/current-time-compare-is-wrong-bug/28454/4 "2022-06-20T22:46:39Z")

</div>

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.

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

---

<div class="post-metadata">

**Author:** ![Yongki](https://avatars.discourse-cdn.com/v4/letter/y/7c8e57/32.png) [@Yongki](https://forum.adalo.com/u/Yongki)\
**Post date:** [June 21, 2022, 3:56am UTC](https://forum.adalo.com/t/current-time-compare-is-wrong-bug/28454/5 "2022-06-21T03:56:25Z")

</div>

I made an example for you.

 ![Screen Shot 2022-06-21 at 10.45.44 AM](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/3X/6/8/68ffd963cb85e41baa7634135e6368cc0751f471.png)

Date Time is a number with lots of fraction digits.

 ![Screen Shot 2022-06-21 at 10.46.04 AM](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/3X/b/f/bff3b5b1e95870c275ca40e972c90ea5d72428a4.png)

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.

 ![Screen Shot 2022-06-21 at 10.46.19 AM](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/3X/f/0/f0297288169baf6aecd4684fdd686bb55ad809a7.png)

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

 ![Screen Shot 2022-06-21 at 10.55.20 AM](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/3X/8/5/85ecc96e404a0039c5009745b38a7d42cd5f35e0.png)

---

<div class="post-metadata">

**Author:** ![Vasily](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/vasily/32/10710_2.png) [@Vasily](https://forum.adalo.com/u/Vasily)\
**Post date:** [June 21, 2022, 4:12am UTC](https://forum.adalo.com/t/current-time-compare-is-wrong-bug/28454/6 "2022-06-21T04:12:42Z")

</div>

> [@Yongki](#):
>
> nt is start of today as reference and 1

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.

---

<div class="post-metadata">

**Author:** ![Yongki](https://avatars.discourse-cdn.com/v4/letter/y/7c8e57/32.png) [@Yongki](https://forum.adalo.com/u/Yongki)\
**Post date:** [June 22, 2022, 8:51am UTC](https://forum.adalo.com/t/current-time-compare-is-wrong-bug/28454/7 "2022-06-22T08:51:06Z")

</div>

You can check the example here,

> [@Free Template - Komun for Community Support - In Progress](https://forum.adalo.com/t/free-template-komun-for-community-support-in-progress/18793/3):
>
> v0.2 First run for data testing Rearrange screens on canvas Add admin boolean field and deleted boolean field Designated admin (admin=true in users collection) can add project and add participants to activitiy, as well as delete them. Deleting project, activity, comment will update the deleted boolean field as true, which makes them hidden from the list, the exceptions are for activity photos and replies as they don’t have child collection to be handled. Add Start Date and End Date as Date…

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.44.10 PM](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/3X/d/4/d48e17dabfb73de1e4385e2805f2d16fd67c4207.png)  
 ![Screen Shot 2022-06-22 at 3.45.17 PM](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/3X/1/9/1972f6003baecfbeebf698b65df269d6fa7fbabf.png)

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.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/system/32/40401_2.png) [@system](https://forum.adalo.com/u/system)\
**Post date:** [July 2, 2022, 8:51am UTC](https://forum.adalo.com/t/current-time-compare-is-wrong-bug/28454/8 "2022-07-02T08:51:53Z")

</div>

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