View Full Version : Resolved pulling date info from db and displaying it frmatted on page?

03-17-2010, 04:48 PM
Hi All,

i am pulling out some dates from a db (which is stored as a date field) and am trying to get it to display on the page as e.g December 2008 instead of 2008-12-12.

i have looked on google and have found out that i need to use F and Y to format the date as i want which is fine, but what im not sure how to do is select the value to be formatted.

i have
echo $row['prodRelease'];

which prints out 2008-12-12 but i am unsure of how to format the date using the F Y???

any help appreciated :)


[Paul Ferrie ]
03-17-2010, 04:54 PM
check out the php manual (http://php.net/manual/en/function.date.php) for date formatting options.

you will be looking to do something like.

echo date("l d'S F, y", strtotime($row['prodRelease']));

hope it helps

03-17-2010, 05:08 PM
hi mate,

thanks for your reply,

i just found out that doing the formatting in the sql query is quicker and easier?

so i have this

SELECT *, DATE_FORMAT(prodRelease, '%e %b %y') AS formatedDate

which is currently giving me 14 Dec 09 just need to find the correct format :)


found the solution

DATE_FORMAT(prodRelease, '%M %Y')

does the trick :D

thanks mate