Reputation: 1
I'm trying to import a date "9:26 AM Thursday Feb 11, 2016" but it only shows "12:00 AM Thursday Feb 11, 2016"
$date = date("h:i A l M j, Y", strtotime("9:26 AM Thursday Feb 11, 2016"));echo $date;
Upvotes: 0
Views: 97
Reputation: 94682
If you use the incredibly flexible DatTime
class it is quite easy.
And using the ->format()
method once you have a valid date loaded you can output it in any format you like
$d = DateTime::createFromFormat('h:i A l M j, Y', "09:26 AM Thursday Feb 11, 2016");
echo $d->format('h:i A l M j, Y');
echo $d->format('d/m/Y H:i');
echo $d->format('d/m/Y H:i l');
Gives this
09:26 AM Thursday Feb 11, 2016
11/02/2016 09:26
11/02/2016 09:26 Thursday
Upvotes: 4