What is the best way to store a date?

I am new to storing dates by time zones.

You need to know the standard way to store dates in a data warehouse.

My requirements

  • Easily request a date based on a date range.
  • show the date with the client selected by the client of the corresponding time zone (I have a table supported for the time zone separately)
  • Ability to query using the data warehouse administrator console.

Any suggestions / ideas regarding this will be useful in the future.

+4
source share
2 answers

Always convert and store data / time in UTC, so that data becomes easily understandable and unambiguous

Convert the date / time to the "local time" of the user to display the target.

+1
source

It is recommended that you store dates in UTC / GMT format in milliseconds. As a result, it will be easy to convert back and forth to the appropriate time zone based on the offset from either the interface or the server. I believe that the date in the database should be zone independent in order to avoid unnecessary complexity.

The best / easiest way to handle calls in the zone is through the user interface using JavaScript, as the client side will always be local time. Several JS plugins are available for this.

Here is one MomentJS

0
source

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


All Articles