John Davidson

php - Convert Time to ISO 8601 format in UTC timezone

0 comments
Message:


I have date as Fri, 15 Mar 2019 08:56:57 +0000


I want to convert this date in ISO 8601 format in UTC timezone in php.


I have tried the following:


$date = new DateTime("Fri, 15 Mar 2019 08:56:57 +0000");
$output = $date->format(\DateTime::ATOM);

Is this correct?



My Answer:
"Fri, 15 Mar 2019 08:56:57 0000");
$date->setTimezone(new DateTimeZone('UTC'));
$iso8601 = $date->format('c');
echo $iso8601;

Rate this post

4 of 5 based on 3992 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us