Best practices for creating timezone enabled apps

I am creating a web application with a timezone enabled and I am looking for the best methods in this regard.

For example, I have user A and User B that have a time zone set. User A enters the time. (in his time zone.) Now how do you store this in the database.

  • [option 1] Original time with original time zone
  • [Option 2] UCT time stored in UCT.

Use cases

  • This time user A should be displayed.
  • User B should be shown this time.
  • User Anon should be shown this time.
  • It is necessary to calculate the difference in time zones.

I see the benefits of both. I'm not really looking for an answer to this question, but information on creating time zone-oriented web applications in particular.

I use Python, but are looking for agnostics of the language as well.

+3
source share
2 answers

Semantically, almost all the times you are manipulating are absolute times (for example: billing, creations and modifications, the last seen, api throttles, SO bounties ...). They should be stored in UTC so that there is no ambiguity in them. Otherwise, when some government changes the DST rule and your system rules are updated, the value you saved will change the value.

(, , ), RFC 3339, ( , UTC offset), UTC .

+4

, , (UTC) , . IP- .

, , . : , , . , - . , , 8.30-9.30pm .

+2

Source: https://habr.com/ru/post/1778484/


All Articles