函数ini_set()设置时区:
可以在文件开头加入 ini_set('date.timezone','Asia/Shanghai'); // 'Asia/Shanghai' 为上海时区
手动修改php.ini设置
打开php找到date.timezone = "PRC" 如有去掉前面的分号,没有的话手动添加!
date_default_timezone_set("Asia/Shanghai");//中国时区 date_default_timezone_set("Etc/GMT-8");//中国时区 echo date("Y-m-d H:i:s",1370424646);//2013-06-05 17:30:46 echo date("Y-m-d h:i:s",1370424646);//2013-06-05 5:30:46