-6

I want check whether the date from variable is older than current date about 7 days or more.

Now, I check whether this date is -1 day from current:

   $old_email = strtotime($result->repairs_date_received) >= strtotime('-1 day') ? true : false;
Kuba Żukowski
  • 653
  • 3
  • 11
  • 16

1 Answers1

0

UNIX time is in seconds, so you can simply check using basic operators like > and <.

$week_ago = strtotime('a week ago');
$check = strtotime($result->repairs_date_received);

if($check > $week_ago){
    // date is newer than week 
} else {
    // date is older than week
}
Matthew R.
  • 4,332
  • 1
  • 24
  • 39