m
is the modifier for months. i
is the modifier for minutes. Getting this wrong will obviously cause issues. Change:
$thedate = date_create_from_format("m/d/Y h:m a", $thestring);
to:
$thedate = date_create_from_format("m/d/Y h:i a", $thestring);