Php 无论发生什么情况,CURTIME都会提前2小时返回

Php 无论发生什么情况,CURTIME都会提前2小时返回,php,mysql,Php,Mysql,我有一个在linux上运行的sql脚本,它来自一个php文件,它总是返回比我们早2小时的时间。linux框在本地运行,当我在shell中执行“日期”时,它返回正确的时间。你知道为什么我会提前两小时回来吗 即使我跑 echo date('Y-m-d H:i:s'); echo date('Y-m-d H:i:s', mktime()); echo exec('date'); 现在对我来说是正确的时间 2013-08-27 12:44:52 2013-08-27 12:44:52 2013

我有一个在linux上运行的sql脚本,它来自一个php文件,它总是返回比我们早2小时的时间。linux框在本地运行,当我在shell中执行“日期”时,它返回正确的时间。你知道为什么我会提前两小时回来吗

即使我跑

echo date('Y-m-d H:i:s'); 
echo date('Y-m-d H:i:s', mktime());  

echo exec('date');
现在对我来说是正确的时间

2013-08-27 12:44:52

2013-08-27 12:44:52

2013年8月27日星期二12:44:52 PDT

但无论我做什么,它都会在14:44:52从mysql插入mysql数据库:

该值以当前时区表示

如果您希望它显示在您的时区中,则需要将其转换为您希望执行以下操作的timzeone:


您的php默认时区设置为什么?大概是以UTC()返回时间。日期默认时区设置(“美国/洛杉矶”);我认为你的问题是重复的
select convert_tz(now(), @@global.time_zone, '-5:00'); 
select date(convert_tz(now(), @@global.time_zone, '-5:00')); 
select time(convert_tz(now(), @@global.time_zone, '-5:00'));

# The second value gets the time of the server so it knows what to convert from.

# The third value is your timezone you want to display
# It can either be an offset, or name (if table is installed): 
# 'UTC', 'PST', 'MET', and so on