Php different timezones [closed]

﹥>﹥吖頭↗ 提交于 2019-12-13 10:47:45

问题


I'm developing a web app in php mysql which should be usable in the whole world. In this app there is a big usage of time so I'm wondering if there is any work to do on the timezones differences or if php is automatically recognizing the different timezones before saving in the db ?

Thanks for your help


回答1:


MySQL Server Time Zone Support

And ensure that you store all dates and times in the database in UTC. It's the only way to remain sane.




回答2:


You can create a function for geting time zone for differenct places

function getDatetimeNow() {

$tz_object = new DateTimeZone('Asia/Karachi');
//date_default_timezone_set('Brazil/East');
$datetime = new DateTime();
$datetime->setTimezone($tz_object);
return $datetime->format('Y\-m\-d\ h:i:s');   

}

for differnect time zone location find it on below link

http://php.net/manual/en/timezones.america.php



来源:https://stackoverflow.com/questions/39247777/php-different-timezones

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