WordPress.org

Forums

If post is older than x days (2 posts)

  1. westondeboer
    Member
    Posted 7 years ago #

    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?

  2. westondeboer
    Member
    Posted 7 years ago #

    <?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
    }
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.