# Problem when comparing dates with timezones

**URL:** <https://community.appfarm.io/t/problem-when-comparing-dates-with-timezones/2347>\
**Category:** Bug reports\
**Created:** [May 11, 2026, 11:22am UTC](https://community.appfarm.io/t/problem-when-comparing-dates-with-timezones/2347 "2026-05-11T11:22:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![oscar.harestad](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/oscar.harestad/32/1659_2.png) [@oscar.harestad](https://community.appfarm.io/u/oscar.harestad)\
**Post date:** [May 11, 2026, 11:22am UTC](https://community.appfarm.io/t/problem-when-comparing-dates-with-timezones/2347/1 "2026-05-11T11:22:15Z")

</div>

Hi!

We have a problem in our solution when comparing dates in differing timezones. See image below.

 ![Skjermbilde 2026-05-11 kl. 09.00.00](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/2X/9/9bb6c04d870f089464e8f4ff205888bf5b662cf2.png)

“Time from API” is a dateTimeOffset acquired from a web request, while “Time Now” is an app variable equal to Date Now. The comparison “Time from API” \< “Time now” equals to false, which is not correct.

However, when “Time from API” is more than 2 hours (our offset from UTC) from “Time now”, the comparison is correct (see image below).

 ![Skjermbilde 2026-05-11 kl. 09.22.50](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/2X/8/8dfafd0a034ffd302c6574ea1559c7a0f9733cbd.png)

Previously, I believe the datetimes in web requests was automatically formatted to UTC “2026-05-11T:xx:xx:xx.xxxZ” instead of “2026-05-11T:xx:xx:xx+02:00” which does not seem to happen anymore.

---

<div class="post-metadata">

**Author:** ![Shahitha](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/shahitha/32/66_2.png) [@Shahitha](https://community.appfarm.io/u/Shahitha)\
**Post date:** [May 11, 2026, 12:14pm UTC](https://community.appfarm.io/t/problem-when-comparing-dates-with-timezones/2347/2 "2026-05-11T12:14:32Z")

</div>

Hi!

What data type is the “Time from API” App Variable set to? The value from the web request has a timezone offset (`+02:00`), while Appfarm uses UTC internally. If the variable is set as a String and not DateTime, you may be comparing two values with different formats.

---

<div class="post-metadata">

**Author:** ![oscar.harestad](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/oscar.harestad/32/1659_2.png) [@oscar.harestad](https://community.appfarm.io/u/oscar.harestad)\
**Post date:** [May 11, 2026, 12:19pm UTC](https://community.appfarm.io/t/problem-when-comparing-dates-with-timezones/2347/3 "2026-05-11T12:19:33Z")

</div>

Hi!

Both variables are Data Type “Datetime” in Create.  
“Time from API” is mapped from a web request which gives the date in +02:00 format.

---

<div class="post-metadata">

**Author:** ![Shahitha](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/shahitha/32/66_2.png) [@Shahitha](https://community.appfarm.io/u/Shahitha)\
**Post date:** [May 11, 2026, 1:31pm UTC](https://community.appfarm.io/t/problem-when-comparing-dates-with-timezones/2347/4 "2026-05-11T13:31:14Z")

</div>

Thanks for confirming!

We tried recreating it in our end and it seems to be working fine.. Would it be possible to test mapping it into a new App Variable set as DateTime type? There might be something off with the current variable.

---

<div class="post-metadata">

**Author:** ![oscar.harestad](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/oscar.harestad/32/1659_2.png) [@oscar.harestad](https://community.appfarm.io/u/oscar.harestad)\
**Post date:** [May 15, 2026, 8:58am UTC](https://community.appfarm.io/t/problem-when-comparing-dates-with-timezones/2347/5 "2026-05-15T08:58:44Z")

</div>

Hi again,

When mapping “Time from API” to another new App Variable, the date seems to be in the correct format and the comparison is correct. This could be a viable solution - but in the original web request where the problem first happened, we receive quite a lot of dates. So this is not a preferable solution.

Another working solution is to update the variable itself using “moment(TimeFromAPI).toJSON()” to format it correctly. This also, however, is tedious and would have to be done to every date received from the web request.

---

<div class="post-metadata">

**Author:** ![kristian](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/kristian/32/58_2.png) [@kristian](https://community.appfarm.io/u/kristian)\
**Post date:** [May 15, 2026, 9:22am UTC](https://community.appfarm.io/t/problem-when-comparing-dates-with-timezones/2347/6 "2026-05-15T09:22:50Z")

</div>

Hi Oscar.

I tried returning that exact same format in a web request, mapping it to a Appfarm date property, and it automatically converts to the correct format (2026-05-11T:xx:xx:xx.xxxZ) - no need for that moment transformation.

Do you have this same issue on all date properties? And, if you map the returned “+02:00”-format to a new date variable, it works?

---

<div class="post-metadata">

**Author:** ![oscar.harestad](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/oscar.harestad/32/1659_2.png) [@oscar.harestad](https://community.appfarm.io/u/oscar.harestad)\
**Post date:** [May 15, 2026, 1:48pm UTC](https://community.appfarm.io/t/problem-when-comparing-dates-with-timezones/2347/7 "2026-05-15T13:48:16Z")

</div>

Hi!

Yes, that is correct. Every date property I map to using web requests will have the same format as received from the API. I have tried multiple APIs using the “…+02:00” format, and the interactions seem to behave in the same way (the properties in the Appfarm dev tools show the dates in the same format). If mapped to any other property, or value processed in any way, the format changes to “…Z” and everything works as expected.

The properties behave as expected (regardless of format) in every case except for the comparison presented above. Displaying the date as text in any form, for example, shows the expected date and time, no matter the format displayed in the dev tools.
