Best practice for localizing application web application time in 201x

I worked on various web projects, but the correct localization of the time for the date was not completed and considered terribly, so I want to ask this typical problem here, and I want to hear expert comments on this problem.

  • What is the correct strategy for storing the date / time from the client from the server.

As I understand it, because of the locale and time zone, so we need to do the conversion, I heard about GMT or UTC, and after some searching it seems that UTC is more accurate? therefore, we will convert from client time β†’ UTC + 0 when saving and when we read the value from server to client, we again convert time from server back to client time? However, I see on some website, below is the sentence "All the time in UTC", "All the time in GMT", as well as "All the time in your local time." So, maybe not all sites do the conversion back and forth? And in this case, the user needs to manually perform the conversion of date and time?

  • How to display a date / time convenient for the user based on his locale and region.

How to provide personalization by date / time? I had one time dependent on vbscript to render, and the format is automatically read from regional and windows format. But without vbscript, we can define a date / time pattern for the user of a particular locale. Do we need to keep the mapping between the locale and the template somewhere and do the server side conversion?

  • Although in most cases a date and time conversion is required, there is a situation where only the date takes place, for example, if my birthday is February 2, 1980, it should be the same for all locales, and the conversion should not be done. How can we solve this problem.
+4
source share
1 answer

Storing dates in UTC is always better. By showing the user, convert it to local time and show

+3
source

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


All Articles