Answer the question
In order to leave comments, you need to log in
Is it correct to set the timezone for PHP equal to the user's timezone?
Hello!
There was a discussion with my colleagues: We have an international project, respectively, users with different timezones. Apparently, in order not to bother with date formatting, when executing the PHP timezone application, it is set equal to the user's timezone (from the profile settings or by definition by IP) using the Yii::app->setTimeZone method, which in turn calls the PHP date_default_timezone_set function). (In principle, this is how Yii2 is advised here . How to display the date depending on the timeZone? )
To be honest, I meet this for the first time. In other projects, the timezone was always set equal to the server's timezone and did not change depending on the user's settings. If it is necessary to display the time in the user's time zone, then it was previously translated into it.
How are you doing? What is the correct approach?
Answer the question
In order to leave comments, you need to log in
Does each user have their own time zone, and even by IP address? Brad what.
What if it's through a proxy? And if this is the IP address of some Megafon for the whole of Russia?
Do you need all this hemorrhoids?
Keep all the time in Greenwich and don't invent bicycles.
If it needs to be shown in the user's zone, the browser itself does this best - the javascript in it knows the time zone actually set on the computer, and does not guess by IP,
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question