当前日期从UTC时区

问题描述:

我们正在将用户时区存储到数据库中,我正在查看UTC时区的当前日期。 我有+5.5,-7,+2.5的时区数据。并希望从时区获得当前时间。当前日期从UTC时区

我如何从PHP或MYsql获取当前日期。

+0

你试过吗? http://*.com/questions/8655515/get-utc-time-in-php –

<?php 

//current time zone to UTC 
$date = new DateTime($datetime, new DateTimeZone(date_default_timezone_get())); 

//set the time zone as UTC 
$date->setTimezone(new DateTimeZone('UTC')); 

//convert local time to UTC time 
$date=$date->format("Y-M-D"); 

echo $date; 

//-------------------------------------------------------------------- 

//UTC to some other time zone format 

$date = new DateTime($datetime, new DateTimeZone("UTC")); 

//set the time zone as UTC 
$date->setTimezone(new DateTimeZone(date_default_timezone_get())); 

//convert local time to UTC time 
$date=$date->format("Y-M-D"); 

echo $date;