码迷,mamicode.com
首页 > Web开发 > 详细

php时区测试

时间:2014-06-04 19:29:01      阅读:372      评论:0      收藏:0      [点我收藏+]

标签:c   style   class   blog   code   java   

php里面关于时间的函数有date,time,strtotime,gmdate等,里面只要和时间字符串相关的基本都收到时区的影响,所以时间戳才是唯一稳定时间记录,因为标准都是统一的。
这里联想到数据库的存储时间字段,虽然不为时间戳更适合数据库存储与查询,还可以用到很多时间函数。但是如果服务器跨时区,或者业务跨大范围地域的还是记录时间戳更好。

时间是2014-05-06

bubuko.com,布布扣
date_default_timezone_set(‘Asia/Shanghai‘);
echo date_default_timezone_get(),
‘:‘; echo strtotime($_GET[‘s_begin_time‘]),‘<br>‘,date("Z",strtotime($_GET[‘s_begin_time‘])),‘<br>‘; echo strtotime($_GET[‘s_begin_time‘])+date("Z"),‘<br>‘; echo time(),‘<br>‘;
date_default_timezone_set(
‘Asia/Tokyo‘); echo date_default_timezone_get(),‘:‘; echo strtotime($_GET[‘s_begin_time‘]),‘<br>‘,date("Z",strtotime($_GET[‘s_begin_time‘])),‘<br>‘; echo strtotime($_GET[‘s_begin_time‘])+date("Z"),‘<br>‘; echo time(),‘<br>‘; date_default_timezone_set(‘GMT‘); echo date_default_timezone_get(),‘:‘; echo strtotime($_GET[‘s_begin_time‘]),‘<br>‘,date("Z",strtotime($_GET[‘s_begin_time‘])),‘<br>‘; echo strtotime($_GET[‘s_begin_time‘])+date("Z"),‘<br>‘; echo time(),‘<br>‘; exit;
bubuko.com,布布扣
bubuko.com,布布扣
时区时间:Asia/Shanghai:1399305600
偏移时间:28800
转换后的标准时间:1399334400
服务器标准时间:1401353087

Asia/Tokyo:1399302000 32400 1399334400 1401353087

GMT:1399334400 0 1399334400 1401353087
bubuko.com,布布扣

 

php时区测试,布布扣,bubuko.com

php时区测试

标签:c   style   class   blog   code   java   

原文地址:http://www.cnblogs.com/kudosharry/p/3759529.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!