Title: Custom date format using post_date
Last modified: August 19, 2016

---

# Custom date format using post_date

 *  Resolved [thx2137](https://wordpress.org/support/users/koyder/)
 * (@koyder)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/custom-date-format-using-post_date/)
 * Hello everyone!
    I’d like to display post date outside the Loop. The only way
   I’ve been able to do that is with $post->post_date. However, it displays date
   in the following format: 2009-05-12 23:51:49, and I’d like to use a custom one(
   j M Y). How could I achieve that?
 * Here’s what it looks like on my site (I’m using a modified Smart Archives plugin):
   [http://superpospolita.pl/archiwum/](http://superpospolita.pl/archiwum/)
 * Any help would be greatly appreciated!

Viewing 9 replies - 1 through 9 (of 9 total)

 *  [Samuel B](https://wordpress.org/support/users/samboll/)
 * (@samboll)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/custom-date-format-using-post_date/#post-1148486)
 * [http://codex.wordpress.org/Formatting_Date_and_Time](http://codex.wordpress.org/Formatting_Date_and_Time)
 *  Thread Starter [thx2137](https://wordpress.org/support/users/koyder/)
 * (@koyder)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/custom-date-format-using-post_date/#post-1148499)
 * That seems to work only with the_date() and the_time(), which I can’t use outside
   the Loop. But I’ve found a solution:
 * `mysql2date('j M Y', $post->post_date);`
 *  [Alkorr](https://wordpress.org/support/users/alkorr/)
 * (@alkorr)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/custom-date-format-using-post_date/#post-1148779)
 * Hi koyder, thanks for sharing!
 * But where do you exactly put mysql2date(‘j M Y’, $post->post_date); to make it
   work properly? I do an echo on post_date to show the date but when I place mysql2date(‘
   j M Y’, $post->post_date); into my code, it doesn’t work…
 * Thanks a lot for your help!
 *  [ricardonunez](https://wordpress.org/support/users/ricardonunez/)
 * (@ricardonunez)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/custom-date-format-using-post_date/#post-1148799)
 * Hi there,
 * I am trying to do exactly the same thing but it does not seem to work.
 * My code:
 * `echo "<li><a href=\"".get_permalink()."\">$post_title</a> - $post->post_date;?
   ></li>";`
 * What I get:
 * “The title” – 2008-10-24 10:22:18
 * What I want:
 * “The title” – October 24, 2008
 * If I change the code to:
 * `echo "<li><a href=\"".get_permalink()."\">$post_title</a> - mysql2date('j M 
   Y', $post->post_date);</li>";`
 * I get:
 * “The title” – mysql2date(‘j M Y’, 2008-10-24 10:22:18);
 * Thanks in advance for the help
 *  [neologan](https://wordpress.org/support/users/neologan/)
 * (@neologan)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/custom-date-format-using-post_date/#post-1148800)
 * you haven’t wrapped the code, it’s just plain text at the moment
 * `mysql2date('j M Y', $post->post_date);`
 * see?
 * try:
 * `. mysql2date('j M Y', $post->post_date) .`
 *  [cheezepie](https://wordpress.org/support/users/cheezepie/)
 * (@cheezepie)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/custom-date-format-using-post_date/#post-1148826)
 * I’m having the same problem…
 * I’m trying to output:
 * `<li><a>Title</a> April 12, 2010</li>`
 * But when I use the code in neologan’s example above I get:
 * `<li><a>Title</a> </li>`
 * Here’s my code:
 * `'<li><a href="' . get_permalink($post["ID"]) . '" title="Read more of '.$post["
   post_title"].'" >' . $post["post_title"].'</a> '.$post["post_date"].' </li> '`
 *  [cheezepie](https://wordpress.org/support/users/cheezepie/)
 * (@cheezepie)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/custom-date-format-using-post_date/#post-1148827)
 * Sorry, missed out the code including neologan’s exmaple in my post above. The
   code including neologan’s example looks like this:
 * `'<li><a href="' . get_permalink($post["ID"]) . '" title="Read more of '.$post["
   post_title"].'" >' . $post["post_title"].'</a> '. mysql2date('j M Y', $post->
   post_date) .' </li> '`
 * But outputs:
 * `<li><a>Title</a> </li>`
 * I’m trying to get:
 * `<li><a>Title</a> April 12, 2010</li>`
 *  [ian92484](https://wordpress.org/support/users/ian92484/)
 * (@ian92484)
 * [16 years ago](https://wordpress.org/support/topic/custom-date-format-using-post_date/#post-1148839)
 * try this:
 * . mysql2date(‘M j Y’, $post[“post_date”]) .
 *  [cheezepie](https://wordpress.org/support/users/cheezepie/)
 * (@cheezepie)
 * [15 years, 12 months ago](https://wordpress.org/support/topic/custom-date-format-using-post_date/#post-1148841)
 * [@ian92484](https://wordpress.org/support/users/ian92484/)
 * That works perfectly! Thanks.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Custom date format using post_date’ is closed to new replies.

## Tags

 * [post_date](https://wordpress.org/support/topic-tag/post_date/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 9 replies
 * 7 participants
 * Last reply from: [cheezepie](https://wordpress.org/support/users/cheezepie/)
 * Last activity: [15 years, 12 months ago](https://wordpress.org/support/topic/custom-date-format-using-post_date/#post-1148841)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
