How to check if a WordPress post date is at least 7 days old

I´d like to create a function that checks if a “post” (wordpress) is older than 7 days. I have the following code so far:

function is_old($start) {

    $now = date("Y-m-d");

}

$start contains the date which I want to check if is more than 7 days prior to $now. How can I do this?

Related posts

Leave a Reply

2 comments

  1. If $start is a date, this works:

    function is_old($start) {
        return strtotime($start) < strtotime('-1 week');
    } 
    

    If $start is a timestamp, you can omit the first strtotime.