Answer the question
In order to leave comments, you need to log in
How to show the user data in his time zone and is it necessary?
The time on the server is in UTC. For all entities, the creation time is measured in timestamp and transmitted to the user in the browser as a timestamp, while the user on the computer is already converted to date and time. Thus, each user sees the date and time according to their time zone.
But there is also the functionality of charts for 7 days.
select count(*) as total, date
from events
where events.created_at > interval - 1 week
group by date
Answer the question
In order to leave comments, you need to log in
1. Sign the date on the charts in the user's time zone. If they are shown exactly for the last N days, then such nuances will be invisible to the end user anyway. If the user selects an arbitrary interval, then already convert.
I advise you to choose one time storage format and use it to the maximum in order to reduce the number of places where the conversion is performed
. Also, move the conversion itself into a separate function, even if it is used in 1 place - in the future it will be easier to change
2. Depends on the nature of the data and tasks, according to what is described in the question, it is impossible to say. Here the question is more to the subject area
The answer is highly dependent on the subject area. If this is the MCC, then no time zones, even Baikonur, even East, even Cape Canaveral - for all UTC. If this is a train schedule, then before the whole country was poisoned and arrived according to Moscow time, but then they decided to do it according to the local time (one can argue about the correctness of the decision, but for foreign passengers it is more logical to see the local time). If you can't decide which option is best, then give users a choice. This is where UI/UX science comes into play, so that choices help the user, not confuse them.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question