I've an object where elements are like
i) "StartTime":"0001-01-01T09:30:00+00:00"
and "Timezone":"NEW YORK"
The time string is a 24hour format and where "+00:00"
is meaningless ie hard coded for all timezone.
I've to convert it to UTC time.
My code-
$startTime = new \DateTime(substr($obj->Session->StartTime, 0, -6));
$startTime->setTimezone(new \DateTimeZone('UTC'));
print_r($startTime);
DateTime Object
(
[date] => 0001-01-01 03:36:40
[timezone_type] => 3
[timezone] => UTC
)
But it should be actually 2:30 pm?
ii) "StartTime":"0001-01-01T08:00:00+00:00"
and "Timezone":"LONDON"
Results to
DateTime Object
(
[date] => 0001-01-01 02:06:40
[timezone_type] => 3
[timezone] => UTC
)
It's wrong again.
Any help please?
I would suggest looking into a solution like NTP (network time protocol). It will be very accurate, as well as come with many tools for manipulation and time zone conversion.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.