• It’s easy to do it?
    What I want is to display Today for the today posts, Yesterday for yesterday posts and else the date of the post
    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • This goes in the loop:

    <?php
    $days_old = (current_time(timestamp) - get_the_time('U') - (get_settings('gmt_offset') *3600 ) ) / (60*60*24);
    if ($days_old <=1) {
      echo 'Today';
    } elseif ($days_old > 1 & $days_old <= 2) {
      echo 'Yesterday';
    } else {
      the_time('F jS, Y');
    }
    ?>

    Thread Starter Lucky-1

    (@lucky-1)

    Nice, thank you
    If I use the_date then will show just 1 time Today, and 1 time Yesterday?
    I messed to say I want that atribute of the date, just to show one time the date value

    I’m from germany and the time is not right for me. how can i change it to make it work for me? f.e.: posts from the late 22nd of september are shown as “today” on the 23rd… please help!

    MichaelH: This code work perfect, except that it displays “Today” for the posts that been posted in 24 hours. I dont want that, I want the text “Today” if it were posted the same day, not the same 24 hours. Please someone help ??

    Bump! I really need help. ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘If the_date = today displays ‘Today’ else the_date’ is closed to new replies.