How to Convert to UTC

我是研究僧i 提交于 2019-12-01 19:01:01

For the first case the offset is there so it should be trivial, the second example however will be considered as UTC (or any other default timezone). This is what I suggest:

date_default_timezone_set('UTC'); // set default timezone

$one = strtotime('Mon, 28 Jun 2010 12:39:52 +1200');
$two = strtotime('2010-06-25 15:33:00'); // Already UTC? Must be...

$one and $two will hold the timestamps of the correspondent time converted to the UTC timezone.

You can use strtotime() to convert whatever time format you have into a timestamp and then use whatever function, probably date(), to put it in the format you want everything to be stored in.

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