[英]CodeIgniter PHP Timezone and Strtotime
我正在使用以下代码来生成时间戳:
date_default_timezone_set('America/Chicago');
$time = strtotime(today 08:30", $day); //$day changes
这将产生1393943400的时间戳= 2014年3月4日09:30:00
理想情况下,我想传递一个时区,但是当我使用CodeIgniter时,TimeZone定义与PHP时区(即UM5 for EST)不匹配。
我欢迎任何想法!
谢谢
我也使用Codeigniter,如果您的PHP> = 5.2.0,则可以使用DateTime对象:
$system_timezone = new DateTimeZone('America/Los_Angeles'); // your timezone
$user_timezone = new DateTimeZone('America/Chicago'); // your user's timezone
$now = new DateTime(date('Y-m-d H:i:s'), $system_timezone);
$now->setTimezone($user_timezone);
echo $now->format('Y-m-d H:i:s'); // you can see the date and time of the desired timezone
希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.