Atozed Forums
Dealing with Local Time - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html)
+--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html)
+---- Forum: English (https://www.atozed.com/forums/forum-16.html)
+----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html)
+----- Thread: Dealing with Local Time (/thread-145.html)



Dealing with Local Time - lfeliz - 05-03-2018

Hello,

Developing an app where users may be in different time zones. In past I never worried about this as system date time stamps matched local time of users.    Now I am looking at  using   Postgres datetime type with time zone support  and need best option for ensuring I have the correct local session time.   Assuming all time is saved as  UTC .

To make maters more interesting it could be case where   driver leaves pt A at  5AM Pacific Time and gets to location at  6PM Pacific time  ( 6 PM Mountain Time) as it crossed a time zone.  The initial  user makes all entries based on   Pacific Time.

User at destination looks at system,  the time would then display for him i mountain time (his local time zone).

Should I set time zone based on setting in user profile or should I get it from the browser setting and have it be dynamic to allow mobile devices to work if user is mobile and goes between timezones. I have some sample code that I will update this ticket with to show what app currently does , but find that it sometimes does not work as desired.


Cheers!


RE: Dealing with Local Time - kudzu - 05-04-2018

In short the best thing to do is store all db records with a single TZ. UTC is good.

Then for each user, you can get their TZ I believe in a browser header and in your Delphi code you adjust the time as part of its formatting that the user sees. It is essentially just formatting. And on the reverse, parse. But post/pre UI, deal only in UTC.

A user should also be able to override their TZ as part of their profile. For example, a user travels and is in a different TZ, but prefers to still see things in their home TZ.