Answer the question
In order to leave comments, you need to log in
How to do work with cities and time zone?
I make a recording service and implement work with several cities in different time zones in it.
The city will be chosen rigidly, the user is rigidly bound to the city.
I plan to do this:
make a field near the city a UTC field, and depending on the city, display their time to users ...
What parks and nuances are there in general? How then to work with the time format?
After all, it will be moderated from completely 3 different cities - so that the manager does not have confusion over time.
UPD: now I have the time stored in the time format, the date in the date format, with such an implementation, will this be the right thing to do?
Answer the question
In order to leave comments, you need to log in
It may be better to use a complex datetime, or even better to store it as an unsigned unixtime (it will work faster, and teaching the model to return a valid DateTime object when reading from this field is not so difficult).
And I would store in UTC, everything is correct, and the user has a separate value - an offset from him in one direction or another. Then you will get rid of a huge pile of problems, the main thing is that the time on the servers (app + db) is correct - strictly according to UTC.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question