Hello Guys,
Today we will learn how to convert the local time period into UTC format :
We will create a function with offset and time as parameter.Below is the code:
function
convertToUTC($DateTimeZone,$offset){
$DateTimeZone='2015-10-28 03:11:00';
$offset='+5:30';
$date = new DateTime($DateTimeZone.$offset);
$date->setTimezone(new DateTimeZone('UTC')); // +05
$date=$date->format('Y-m-d H: i: s');
echo $date;
}
Following will convert the local time to the UTC format.Enjoy!!
0 Comment(s)