Take datetime from json response

My case is i am trying to retrieve data from response like below.

When i take it directly with this function.

Date changed to +1 days. Not the same as I took

How to solve it ?


Hi Imas.

I believe you're having an issue related with the time zone.

Is your server on the same time zone as you? 

Hi Goncalo,

yes, my server on the same time zone

You have a solution?


There are 3 timezones relevant here:

 - The server that has the REST service

 - The OutSystems server

 - Your device

So asking Gonçalo question again, with a little twist:

Are all 3 timezones the same?

Also,  is the OutSystems server On Premise or in OutSystems Cloud?


João Rosado

Hi Joao,

REST Server with the same time zone
The OutSystem server is not the same time zone
Devie same time zone

And I use a Outsystems private cloud.


Imas Deny

Exactly João.

Basically, Imas, you need to convert your dates according to the timezone that you're using the application, since some conversions can be made at the device level or your server level.

Dates in P10 are a bit tricky to deal with when we have several elements on several timezones and is actually something that could be more clear (but is something not easy to bring to the platform, I suppose).

Imas, have you tried to store date and time on separate attributes?

I once had that issue and I think I was able to solve it by doing this on the sync.

Hi Goncalo,

Thank you for suggestion.
Actually i just want to display the current date without time.
Can you help me by giving a screen shoot for its implementation.


Imas Deny

Before going that way, I have another question :)

Do you have control over the REST service? Your problem would be solved if that date time in the JSON had a timezone specified. So assuming it's a GMT+1 timezone, instead of "2017-07-24 04:53:02" it should be either "2017-07-24T04:53:02+01:00" or "2017-07-24T03:53:02Z"

So what is happening:

 - The REST service replies with a date without any timezone information ("2017-07-24 04:53:02")

 - The OutSystems Server reads that and since there is no information assumes it is on the same time as itself.

 - Then sends that datetime to the client and converts to the device timezone.

João Rosado

Hi Joao

Unfortunately, I have no control for REST service
Is there another solution? As said in goncalo


Imas Deny

Hi João,

Doesn't the REST server assume it's UTC? I recall something along those lines...


@Kilian When there is no timezone specified it assumes the local time of either the server (if the JSON conversion is done in a Server Action) or the device (if the JSON conversion is done in a Client Action).
This is aligned with the behavior of the TextToDateTime builtin action.

@Imas even if you need to only show the Date, it can still have a difference if something happens near midnight. It could be converted to a different day.
That said, you can add a OnAfterResponse callback to your REST Api and use the Text extension to do a small regex replace on the Response Body to transform a DateTime into a Date (don't forget to change the Type in the structure attribute to Date as well).

The search string should be something like: """createdate""\s*:\s*""(\d{4}-\d{2}-\d{2}) \d{2}:\d{2}:\d{2}"""

and replace by: """createdate"": ""$1"""

Edit: fixed the replace text that had undesired \s parts.

João Rosado

Hi Joao,

Thanks for the help, before I have got the solution by reducing the default amount of time from outsystems, with the time difference.


Imas Deny.

Not sure from your reply if you kept your previous solution or tried my alternative.

The problem with any solution that adds/subtracts hours in an attempt to fix it is that it will only work half of the year because of day light savings. It may look like it's working for now ..but it's only hiding the problem.

Joâo Rosado

Hi Imas,

You may want to check out the forge timezone component https://www.outsystems.com/forge/component/500/time-zone/ ?

I've had similar problems in the past, and the approach was to save the received JSON date as UTC. Then using the timezone component to convert to whatever timezone and date format that corresponds to the user. This is with the assumption that users will be from different timezones than my server timezone.

Hope this helps.

Kind regards,

Boney Sze