[英]How to convert a local time to utc in php
I have a local time 09:45 AM
. 我的当地时间是09:45 AM
。 How can i convert it into UTC format. 我如何将其转换为UTC格式。 I tried something like this gmdate('Ymd H:i:s', $busSchedule->end_time);
我试过这样的gmdate('Ymd H:i:s', $busSchedule->end_time);
Here $busSchedule->end_time
contains the local time. $busSchedule->end_time
包含本地时间。 But it gave me an error 但这给了我一个错误
A non well formed numeric value encountered 遇到一个非常好的数值
Try this 尝试这个
<?php
$end_date_time = date("Y-m-d")." ".$busSchedule->end_time;
echo $current_date_time = date("Y-m-d H:i:s A",strtotime($end_date_time));
echo "<br>";
echo $utc_date_time = gmdate("Y-m-d H:i:s A",strtotime($current_date_time));
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.