我已经设置了我的 mysql db:SET time_zone = 'America/Los_Angeles';
并在 php
date_default_timezone_set('America/Los_Angeles');
但是当我添加
$time = strtotime ("+2 minutes");
和
$time2 = gmdate("Y-m-d H:i:s", $time);
到 db 当我从 mysql 得到它时,我错了一个小时,如下所示:
$query ="select UNIX_TIMESTAMP("time"), time2 from tbl;
if ($result = $conn->query($query)) {
while ($row = $result->fetch_assoc()) {
$unix_time = $row["UNIX_TIMESTAMP("time")"];
$unix_time2 = $row["time2"];
}
$result->close();
} ,
echo gmdate("Y-m-d H:i:s", $unix_time)." | ".gmdate("Y-m-d H:i:s", $unix_time2)." ";
显示:
2010-12-26 01:06:48
|2010-12-26 02:06:24