PHP adjust time zone for date

三世轮回 提交于 2019-12-30 10:33:11

问题


Quick question,

The following output on my website is -1 hr, and I just wanted a quick fix to adjust it accordingly, but I'm not sure of the correct syntax...

<?php echo date('D, jS F @ g:ia', strtotime($row->datetime)); ?>

Any advice?


回答1:


Use the date_default_timezone_set function of PHP to set the your timezone as default it is taking the timezone of server.

Here is the list of timezones.




回答2:


set default time zone

$timezone = 'America/Los_Angeles';
$stored_time = '2011-01-30 18:23:49';

date_default_timezone_set($timezone);
$timestamp = strtotime($stored_time);
$local_time = $timestamp + date('Z');
$local_date = date('Y-m-d H:i:s', $local_time);

echo $local_date;


来源:https://stackoverflow.com/questions/17425587/php-adjust-time-zone-for-date

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!