相关疑难解决方法(0)

PHP strtotime()函数错误1小时?

在将日期和时间插入MySQL数据库之前,我使用PHP将日期和时间转换为时间戳.

我的问题是,当我使用PHP的strtotime函数时,输出时间戳比实际时间晚-1小时.

例如,考虑今天的日期:2010年7月21日.当我使用PHP代码时:

<?php
$my_timestamp = strtotime("07/21/2010");
echo $my_timestamp;
?>
Run Code Online (Sandbox Code Playgroud)

发回的时间戳是GMT等效MINUS 1小时.即我回来了:2010年7月20日23:00:00 GMT而不是2010年7月21日00:00:00 GMT.

我住在英国所以我的时区是GMT.我已经使用date_default_timezone_set('Europe/London')在脚本中声明了我的时区,并且我还确保将php.ini文件设置为'Europe/London'.

这可能与夏令时有关吗?如何在不添加1小时的所有日期的情况下解决问题?

php mysql strtotime unix-timestamp

14
推荐指数
1
解决办法
1万
查看次数

标签 统计

mysql ×1

php ×1

strtotime ×1

unix-timestamp ×1