WordPress.org

Support

Support » How-To and Troubleshooting » If post is older than x days

If post is older than x days

  • I want to do an if statement where, if post is newer than this date do this, but if post is older than this date do that

    Anyone have any ideas?

Viewing 1 replies (of 1 total)
  • <?php
    $today = date(“r”);
    $articledate = get_the_time(‘r’);
    $difference = round((strtotime($today) – strtotime($articledate))/(24*60*60),0);

    if ($difference >= 25) {
    Do Stuff Here
    }else{
    Do Stuff Here
    }
    ?>

Viewing 1 replies (of 1 total)
  • The topic ‘If post is older than x days’ is closed to new replies.
Skip to toolbar