View Full Version : Converying old dates

06-13-2005, 08:37 AM
I have a system that grabs dates from a mysql database ranging from a few days ago. They come out in the format yyyy-mm-dd, is there any way to convert this to something more usefull like, Saterday, May 30th. I looked at some other posts, but they all seem to be relating to today rather than old dates.


06-13-2005, 11:06 AM
You could try strtotime() to convert your date into a timestamp then use date to change it into a nicely formatted date. For instance (in the following example, $data should contain your db date value):

$data = "2005-06-13";
$formatted = date('l \t\h\e jS \o\f F, Y', strtotime($data));
echo $formatted;
Generally it's more useful to store the unix timestamp if you have the option, rather than a pre-formatted date, since it's easier to manipulate, but hopefully the above will do what you want :)

06-13-2005, 06:45 PM
You are a genious! Works great, thanks so much. :thumbsup: