When I run this, the first one is correctly created on the date. The second fails, returning boolean , and therefore I cannot format. Is time out of range?
//works correctly $startDate = "2015-05-06 10:49:20.637133"; $start = DateTime::createFromFormat('Ymd h:m:s.u',$startDate); echo $start->format('m/d/y'); //doesn't work correctly $startDate = "2015-05-12 15:49:06.821289"; $start = DateTime::createFromFormat('Ymd h:m:s.u',$startDate); echo $start->format('m/d/y');
Code to reproduce the error
string php datetime format
depperm
source share