Php different timezones [closed]

2019-09-22 06:00发布

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

2条回答
神经病院院长
2楼-- · 2019-09-22 06:02

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.

查看更多
Fickle 薄情
3楼-- · 2019-09-22 06:19

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

查看更多
登录 后发表回答