Format post date in WordPress
We all know that $post->post_date
will display post date in the following format: 2011-08-19 17:23:25
. The problem is that, if we want to display post date in different format, what should we do?
Fortunately, WordPress has a very useful function mysql2date
. Suppose you want to display only Month and Year of the post, you should be able to do that using this snippet:
< ?php echo mysql2date('F Y', $post->post_date) ?>
The first parameter of this function can be referred in date function of php.net