mcbeav
mcbeav

Reputation: 12275

Check if date is between 24 hours and 48 hours in the future

I am trying to compare two dates, I want to perform an action depending on if the date being checked is more than 24 hours from the current date and time and less than 48 hours, I have some code here but I am not sure how to compare the dates to the 24 and 48 hours, any help would be greatly appreciated:

$dateBeingChecked = /* Queried value */

$todays_date = date("m-d-Y-H-i-s");

$today = strtotime($todays_date);


if ($dateBeingCheckede > $today + /* 24 HOURS FROM NOW */ && $today < $dateBeingChecked + /* 48 HOURS FROM NOW */) {
     $valid = "yes";
} else {
     $valid = "no";
}

Upvotes: 0

Views: 288

Answers (1)

zerkms
zerkms

Reputation: 255115

Use strtotime:

strtotime('+24 hours')

Upvotes: 2

Related Questions