亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

php - Use datetime type to store time, how to solve the time zone problem
某草草
某草草 2017-05-16 13:08:23
0
7
882

The database uses the datetime field type to record time. How to set the server time zone, mysql time zone, and PHP time zone?

Option 1.
All servers use the UTC time zone uniformly. The PHP program uses the UTC time zone. The datetime type time written to the database is UTC, and it is taken out and converted to the local time zone.

Option 2.
The time zone of all servers can be set arbitrarily, and the program time zone can be set arbitrarily. However, all those involving time storage use the int type to store timestamps.

某草草
某草草

reply all(7)
我想大聲告訴你

Why don’t you set your database to Asia/Shanghaithis time zone for PHP?

迷茫

The time zone of the server must be unified. Usually I record timestamps in the database. Because I find it convenient to search. For cross-border visits. Just perform the corresponding processing when formatting the timestamp.

巴扎黑

Only timestamp is recommended

大家講道理

Finally I understand why time must be timestamped. It turns out it is because of time zone issues. However, the carbon class in Laravel seems to have solved this problem. You can convert the time format at will. Of course, timestamp performance is the most powerful, especially when searching, the int type is much more efficient than datetime.

伊謝爾倫

Strictly speaking, no matter where you are on the earth, the timestamp at any point in time is the same. For example, the timestamp 1452783600 is 4 pm in Paris and 7 am in San Francisco. This is helpful for online and client-side distributed applications to uniformly track time information.

Peter_Zhu

+8 hours. In addition, it is best to save all time formats with timestamps. Timestamps will not have time zone problems. Timestamps have no concept of time zones.
Strictly speaking, no matter where you are on the earth, the timestamp at any point in time is the same.

洪濤

1. Use datetime,php/mysql時區(qū)設(shè)置為UTC+08
2.使用int,直接存時間戳,顯示的時候再使用date to format it

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template