date - php date_create_from_format returning incorrect time -


i'm trying take date provided external system , convert datetime use in mine. however, running issues date_create_from_format function causing wrong information appear.

i receiving date , time string function (that have confirmed correct when call directly). string used construct datetime object using format string matches 1 called format string before returned me. however, resulting datetime object full 12 hours off. example code follows:

var_dump($object->getendtime()); //string(19) "2017-04-04 18:26 pm"  //formatted in function  //$endtime = date('y-m-d g:i a', $endtime); //return $endtime;  $endtime = date_create_from_format('y-m-d g:i a', $object->getendtime()); var_dump($endtime); //object(datetime)#150 (3) { ["date"]=> string(26) "2017-04-05 06:26:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "america/new_york" }  

as demonstrated, appears date_create_from_format function taking hours value , moving forward match 12-hour time, despite matching formats, , not providing am/pm value. there i'm missing regarding function?


Comments