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

Format post date in WordPress
Tagged on:     

One thought on “Format post date in WordPress

  • August 8, 2014 at 7:17 PM
    Permalink

    Sometimes comments need to be tested.

    Reply

Leave a Reply