Display server date times saved in different client time zones
Application Type
Reactive
Service Studio Version
11.11.3 (Build 43291)

Hello everyone and thank you for your time.

In my project, clients can submit requests and I am saving the date time of that request at CreatedAt attribute.

Keep in mind that the app is online and that my server is always on UTC. So some requests were order on wintertimme and others on summertime. That means that:

According to that, I have to questions:

1) Imagine that I am displaying today (summertime) the hour saved in january and the hour saved in june. In OutSystems reactive, database hour will be converted to client side hour when data is displayed to the user. That means that both hours will appear today as 15:00?

2) Now, imagine that I want to export some data (server side action). How can I have the right data chosen by client? How can I export 14:00 for the january request and 15:00 for the June request?

Thank you guys.

Joana


Hello Joana,

I am assuming that you already have a way to set/ obtain a user's timezone at the time of their sign up/ registration.

1) If you are storing only the UTC time in the database and merely converting it to user timezone - without factoring in daylight savings (1 hour difference), then yes, in your example both the hours will appear as 15:00 because current month is June.

2) To export 14:00 and 15:00 in your example, I would suggest saving the user's local datetime as a separate attribute in the database in addition to the UTC value for display/ export purposes. Calculating it based on the UTC value + Daylight savings (true/false) is another option but maybe debatable based on other factors.

Hope this helps some?

Regards,

AJ

Hi Joana,

1) depends on whether you have a datetime or a time.  For datetime there is automatic conversion between server timezone and user timezone in reactive, and this works correctly for saving daylight.  So a database value of 2021-02-14 12:00 will show in Belgium (UTC+1) as 2021-02-14 13:00 and a database value of 2021-07-18 12:00 will show in Belgium (UTC+1) as 2021-07-18 14:00.  None of this is true for time data type, all conversions, if you want them, have to be done explicit.

2) if report is run on server, if you don´ t do anything extra all datetimes will be reported in their database value.  So if you want a datetime reported in the timezone of the user currently viewing the report, you could pass timezone from client to server and convert based on that.  I´ m sure there are forge components for that.  But think carefully if this is what you want, if I´ m your user and I´ m on holiday in another timezone, I´ d be very confused about what I´ m reading in the report.

Alternatively, you might want the report in a given timezone, not necessarily the one the report requester is currently in.  Maybe a site property for each tenant, saying what timezone all reporting has to be done in.  Or maybe even per user, storing their default timezone. 

But even this might not be what you want, depending on the functional meaning of the datetimes you are looking at.  If you want to report in the datetime as it was for your user in the timezone he happened to be in, then the automatic conversion is actually not your best friend, as that information is lost.  For example, user keeps a log of tasks being done.  If he completes a task at 10 while being on holiday, he might want that reported as 10.  In these cases you might be better off using a separate date and separate time attribute, so no automatic conversions happen.  Alternatively, you´ d have to store the timezone the task was completed in with your datetime. 

Dorine

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.