1

我创建了一个表,付款时间payment_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP在我的数据库中。当我在将 payment_time 字段保留为空白的同时插入一个值时,时间已存储在 GMT -7 上,而我在 GMT +00 上停留。我认为这是因为服务器时区是 GMT -7。如何将本地时间插入数据库?即使不可能,那么我至少希望在从数据库输出时获得本地时间(我的意思是在查询时)。

4

2 回答 2

1

看看这个。http://dev.mysql.com/doc/refman/5.5/en//time-zone-support.html

要更改全球时区:

mysql> SET GLOBAL time_zone = timezone;
于 2013-02-07T11:03:11.137 回答
0

将时区设置命令放入该脚本中,从其中插入时间SET time_zone = 'country_name/city';,您可以通过 php 网站中不同国家和州的链接。假设我正在执行 xyz.php 脚本,它将时间插入数据库,那么它应该看起来像这样

<?php date_default_timezone_set('Asia/Kolkata'); //you ned to put this line of code at the start of the script ?>
于 2013-02-07T10:07:34.463 回答