Reputation: 157
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?
Upvotes: 2
Views: 987
Reputation: 124778
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
.
Upvotes: 7
Reputation: 18721
If $start
is a timestamp you have just to do
$days_old = (time() - $start) / 86400
Upvotes: 1