Php 如何将日期时间转换为UTC格式?
我有这种格式的时间,我想把它转换成Php 如何将日期时间转换为UTC格式?,php,datetime,Php,Datetime,我有这种格式的时间,我想把它转换成UTC时区 : "2015-03-17T07:46:52+0100" : "yyyy-MM-dd'T'HH:mm:ssZ" 我正在使用Codeigniter框架。使用DateTime对象非常简单 $string = "2015-03-17T07:46:52+0100"; $dt = new DateTime($string); $dt->setTimezone(new DateTimeZone('UTC')); echo $dt->format
UTC
时区
: "2015-03-17T07:46:52+0100"
: "yyyy-MM-dd'T'HH:mm:ssZ"
我正在使用Codeigniter框架。使用DateTime对象非常简单
$string = "2015-03-17T07:46:52+0100";
$dt = new DateTime($string);
$dt->setTimezone(new DateTimeZone('UTC'));
echo $dt->format('Y-m-d H:i:s');
使用DateTime对象非常简单
$string = "2015-03-17T07:46:52+0100";
$dt = new DateTime($string);
$dt->setTimezone(new DateTimeZone('UTC'));
echo $dt->format('Y-m-d H:i:s');
试试这个例子
(但这确实使用了类)
更新:
如果没有任何课程,您可以尝试以下内容:
$the_date = strtotime("2015-03-17T07:46:52+0100");
echo(date_default_timezone_get() . "<br />");
echo(date("Y-d-mTG:i:sz",$the_date) . "<br />");
echo(date_default_timezone_set("UTC") . "<br />");
echo(date("Y-d-mTG:i:sz", $the_date) . "<br />");
$the_date=strotime(“2015-03-17T07:46:52+0100”);
echo(日期默认时区get()“
”);
echo(日期(“Y-d-mTG:i:sz”,$the_日期)。“
”;
echo(日期、默认时区、设置(“UTC”)。“
”;
echo(日期(“Y-d-mTG:i:sz”,$the_日期)。“
”;
试试看例子
(但这确实使用了类)
更新:
如果没有任何课程,您可以尝试以下内容:
$the_date = strtotime("2015-03-17T07:46:52+0100");
echo(date_default_timezone_get() . "<br />");
echo(date("Y-d-mTG:i:sz",$the_date) . "<br />");
echo(date_default_timezone_set("UTC") . "<br />");
echo(date("Y-d-mTG:i:sz", $the_date) . "<br />");
$the_date=strotime(“2015-03-17T07:46:52+0100”);
echo(日期默认时区get()“
”);
echo(日期(“Y-d-mTG:i:sz”,$the_日期)。“
”;
echo(日期、默认时区、设置(“UTC”)。“
”;
echo(日期(“Y-d-mTG:i:sz”,$the_日期)。“
”;
您想转换为UTC 0表示世界时您想转换为UTC 0表示世界时