Problem displaying formatted date using DATE_FORMAT
-
I’m using the following to display a list of recent news (“News” category) on the main page:
$news=$wpdb->get_results("SELECT p.ID, p.post_title, p.post_date FROM wp_posts p , wp_term_taxonomy t , wp_term_relationships r WHERE p.ID = r.object_id and r.term_taxonomy_id = t.term_taxonomy_id and p.post_type = \"post\" and t.term_id = \"4\" and p.post_status = \"publish\" ORDER BY ID DESC LIMIT ".$how_many); foreach($news as $np){ printf ("<li><small>%s: </small><a href=\"http://mikinduri.com/blog/archives/%s\">%s</a></li>", $np->post_date,$np->ID,$np->post_title); }?>The result is this:
# 2008-07-03 10:39:01: Vogue Optical Donates Sunglasses
# 2008-05-21 09:01:42: Compost Sale
# 2008-01-21 09:37:27: Mikinduri Foundation back on track
# 2008-01-02 12:17:07: Very Sad News: MCoH Worker Murdered
# 2007-12-07 10:58:55: MCoH on CBC News, The NationalI would like to format the date. Prior to upgrading to WP 2.6 I used this in my SELECT statement and it worked:
DATE_FORMAT(p.post_date, ‘%M %D, %Y’)
However, when I use the DATE_FORMAT function now, the above code returns this:
# : Vogue Optical Donates Sunglasses
# : Compost Sale
# : Mikinduri Foundation back on track
# : Very Sad News: MCoH Worker Murdered
# : MCoH on CBC News, The NationalWhy does the formatted date not get printed?
The topic ‘Problem displaying formatted date using DATE_FORMAT’ is closed to new replies.