i have 2011-08-03 21:56:41 coming from a MySQL timestamp and I would like to convert it to Wednesday August 3rd, 2011 using PHP (Not MySQL). How can this be done?
Use strtotime()
to convert your date/time string to a Unix timestamp so you can use date()
to format the value of that timestamp any way you want.
$stamp = '2011-08-03 21:56:41';
echo date('l F jS, Y', strtotime($stamp));
// output: Wednesday August 3rd, 2011
The reference at the date()
manual page is extremely useful. I still reference it all the time for the list of special format characters.
The strtotime()
function sort of seems like magic at first. For future reference, here's the supported date/time documentation on what input formats strtotime()
can accept.