Answer the question
In order to leave comments, you need to log in
Working with timezones in Yii if dates and times are stored in MySQL in DATETIME format?
There is a very large project on Yii 1.1, in which work with the MySQL database is carried out in 95% of cases through СActiveRecord, and in the remaining 5%, which cannot be avoided, by direct complex queries. In the database, fields of the DATETIME type are used for the date and time, now everything is in Moscow time. The project is designed, in fact, only for the Russian Federation, maximum for the CIS. Time zones needed to be added. What is the best way to do this? Converting everything to TIMESTAMP is not that lazy, but inconvenient because of a bunch of code that will need to be rewritten, so we are looking for a way to use Yii's capabilities in working with time zones without making changes to the database.
Answer the question
In order to leave comments, you need to log in
If you want to use time zones, you can't do without conversion anyway.
Moreover, the original time is not stored in UTC, but in Moscow. Or you will have to write a bicycle to calculate the time in the desired time zone relative to Moscow, which will be a wild crutch.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question