bobthegoalie bobthegoalie - 5 months ago 44
PHP Question

Convert String (ISO) to Date PHP

I am trying to convert a string to a date in

. The string I receive is formatted:-




When I try this

$newDate = DateTime::createFromFormat("c", $exp);
$expirationDate = $newFormat->getTimestamp();

fails. Even when I try

$newDate = DateTime::createFromFormat(ISO8601, $exp;
$expirationDate = $newFormat->getTimestamp();

still fails.

Any suggestions are greatly appreciated.


You can try like this:-


$time = "2016-07-16T1:22:04.324+1030";

echo date("d M, Y",strtotime(date($time)));


Output:- 16 Jul, 2016 :-

Reference taken:-

Converting ISO 8601 format to d M Y in PHP

Note:- you can change format of date according to your convenience. like D M d Y h:i:s O T . I checked this code on PHP 5.5.4 , PHP 5.5.14, PHP 7