M
M
mitaichik2016-05-17 18:32:58
Yii
mitaichik, 2016-05-17 18:32:58

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

2 answer(s)
A
Adamos, 2016-05-17
@Adamos

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,

E
entermix, 2016-05-17
@entermix

Something like this:

  • Change the zone depending on the user's settings (i.e. when he chooses his own time zone)
  • Form the date on the client side, i.e. JS, see XDate for example

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question