Support » Plugins » If the post date is today

Viewing 5 replies - 1 through 5 (of 5 total)
  • If it is in the loop can’t you do something like

    the_date('F j, Y')==date('F j, Y')



    Whenever I actually type the_date, it actually displays. I’m not sure why… but it’s a pain in the butt! 🙂

    Well of course it displays the date because that is what it is supposed to do! As you are finding, my suggestion won’t work.

    Looking at some of the core code you might be able to do something like:
    $post_date = mysql2date("Ymd\TH:i:s", $post->post_date_gmt);

    and then use $post_date in your test.

    I’ll have to play around with that…

    Well this will assign the post date to a variable
    <?php $post_date = mysql2date("Ymd", $post->post_date_gmt); ?>

    so your test would be:


    That was the key, MichaelH! Thanks! I’ve now got a specific class applied to my date on my posts that provides a note that it was ‘Today’. Woohoo!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘If the post date is today’ is closed to new replies.