L
L
lexstile2022-04-03 22:33:50
git
lexstile, 2022-04-03 22:33:50

What is the best way to organize work with time zones?

You need to display dates in the user's time zone.
What is the best way to do this?

Option 1:
1. Write to the database in GMT (+00:00).
2. Before sending to the client (FE), we translate according to the time zone specified in the settings (it can be changed at any time).

Option 2:
1. Write to the database in GMT (+00:00).
2. We send the value from the database to the client.
3. Next, at the front (via JS), we translate to the desired time zone.

Or some other option?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Yarkov, 2016-08-13
@denisbookreev

git clone -b design --single-branch git://domain.com/repo.git

D
dollar, 2022-04-03
@lexstile

Option 2. The
server, in general, does not need to know the client's time zone, unless you have some business processes tied to it.
Let me remind you that on the client, if the user has not set a zone, by default, you can automatically determine the zone (that is, use local time). And if you suddenly set it, then in theory you can update the time display without an extra request to the back.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question