Problem when comparing dates with timezones

Hi!

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

“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).

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.

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.

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.

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.

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.

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?

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.