简体   繁体   English

设置MySQL的时区

[英]Setting timezone for MySQL

Im using php to set the current timezone for a site: 我正在使用php为网站设置当前时区:

date_default_timezone_set('America/New_York');

How could I, at the same time, set the same time zone for mysql so that when I use NOW() it uses the timezone set in php? 我如何在同一时间为mysql设置相同的时区,以便当我使用NOW()时使用php中设置的时区?

Don't. 别。

The best practice is to store UTC in the database. 最佳做法是将UTC存储在数据库中。

You can change your Mysql timezone using SET time_zone = timezone; 您可以使用SET time_zone = timezone;更改Mysql时SET time_zone = timezone;

http://dev.mysql.com/doc/refman/5.1/en/time-zone-support.html http://dev.mysql.com/doc/refman/5.1/en/time-zone-support.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM