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.
Jump to Post
2011-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,$tmpdate,$tmpdate); $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.
All 5 Replies
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.