Support » Fixing WordPress » Custom date format using post_date

Viewing 9 replies - 1 through 9 (of 9 total)
  • 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);

    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!

    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

    you haven’t wrapped the code, it’s just plain text at the moment

    mysql2date('j M Y', $post->post_date);



    . mysql2date('j M Y', $post->post_date) .

    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> '

    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>

    try this:

    . mysql2date(‘M j Y’, $post[“post_date”]) .


    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.