Espen Arnoy Espen Arnoy - 2 years ago 99
PHP Question

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");


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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download