Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dealing with Local Time

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.

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.

Forum Jump:

Users browsing this thread: 1 Guest(s)