以美洲太平洋时区格式保存日期 MySQL
Save date in America Pacific timezone format in MySQL
我正在尝试以美洲太平洋时区格式保存日期。我在查询之前执行以下查询
SET time_zone='-09:00'
但是当我关闭连接并重新打开它时,日期似乎是本地格式。你知道为什么吗?
您需要编辑 my.cnf 并重新启动以永久设置它。
基本上你会想要将这一行添加到 /etc/my.cnf
default_time_zone='-09:00'
有关详细信息,请参阅这些文章。
How do I set the time zone of MySQL?
http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_time_zone
每 MySQL Documentation on Time Zone Support
SET time_zone = timezone;
是针对每个连接的设置,因此当连接重置时,它会重置为默认值。
Per-connection time zones. Each client that connects has its own time
zone setting, given by the session time_zone variable. Initially, the
session variable takes its value from the global time_zone variable,
but the client can change its own time zone with this statement:
mysql> SET time_zone = timezone;
如果你想全局设置它,那么你可以
更改配置文件(.cnf
文件)以反映更改
(或)
如果您有 SUPER
权限,那么您可以在运行时使用以下命令设置全球服务器时区值
SET GLOBAL time_zone = timezone;
我正在尝试以美洲太平洋时区格式保存日期。我在查询之前执行以下查询
SET time_zone='-09:00'
但是当我关闭连接并重新打开它时,日期似乎是本地格式。你知道为什么吗?
您需要编辑 my.cnf 并重新启动以永久设置它。
基本上你会想要将这一行添加到 /etc/my.cnf
default_time_zone='-09:00'
有关详细信息,请参阅这些文章。
How do I set the time zone of MySQL?
http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_time_zone
每 MySQL Documentation on Time Zone Support
SET time_zone = timezone;
是针对每个连接的设置,因此当连接重置时,它会重置为默认值。
Per-connection time zones. Each client that connects has its own time zone setting, given by the session time_zone variable. Initially, the session variable takes its value from the global time_zone variable, but the client can change its own time zone with this statement:
mysql> SET time_zone = timezone;
如果你想全局设置它,那么你可以
更改配置文件(.cnf
文件)以反映更改
(或)
如果您有 SUPER
权限,那么您可以在运行时使用以下命令设置全球服务器时区值
SET GLOBAL time_zone = timezone;