How to convert Eastern Time Zone to CENTRAL TIME ZONE

大兔子大兔子 提交于 2019-12-20 01:42:21

问题


I have a time that is being in Eastern Time Zone, but I want to adjust it to CENTRAL TIME ZONE. Both time zones are in USA. I never do it before? I don't know how to convert it. Please help me?


回答1:


This is one possible method:

$dt = new DateTime('2011-02-22 16:15:20', new DateTimeZone('America/New_York'));
echo $dt->format('r') . PHP_EOL;

$dt->setTimezone(new DateTimeZone('America/Chicago'));
echo $dt->format('r') . PHP_EOL;

You can get a list of available time zones with:

print_r(DateTimeZone::listIdentifiers());



回答2:


http://www.builderau.com.au/program/php/soa/Get-the-correct-time-by-converting-between-time-zones-with-PHP-and-PEAR/0,339028448,339273806,00.htm

Or use Zend_Date.




回答3:


Central Time is always 1 hour earlier than Eastern Time. To convert Eastern Time to Central Time, subtract one from the value of Eastern Time.



来源:https://stackoverflow.com/questions/5079811/how-to-convert-eastern-time-zone-to-central-time-zone

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