The mysql database I set up used date format for the field. Consequently dates have to be entered as 0000-00-00. So when I retrieve the field name news_date from the database it will print as 2011-02-02. I would like to display it as February 2, 2011. Can someone help me with the code to make this happen? Thanks.
printman55
0
Light Poster
Recommended Answers
Jump to Post2011-02-02? Which one is the day and which is the month? :P
Assuming it's sql standard it's y-m-d// assuming $sqldate came from the database $tmpdate=explode("-",$sqldate); $newtime=mktime(0,0,0,$tmpdate[1],$tmpdate[2],$tmpdate[0]); $newdate=date("F j, Y",$newtime);
That's the long way around, I'm sure others know a shorter/quicker way but this should work.
…
Jump to PostSELECT DATE_FORMAT( curdate( ) , '%M %e, %Y' ) AS showdate
or in php you can get by using,
date("F j, Y", strtotime($res['news_date']));
All 5 Replies
dietdew12z
8
Junior Poster
paulrajj
6
Junior Poster
printman55
0
Light Poster
dietdew12z
8
Junior Poster
paulrajj
6
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.