- abs: documentation ( source)
- floor: documentation ( source)
- date: documentation ( source)
- strtotime: documentation ( source)
- define: documentation ( source)
<?php
define('DAY', 24*60*60, true);
$startDate = date('F d, Y');
$AdExpirationDate = date("F d, Y",strtotime($startDate . '+20 days'));
//Calculate the difference between expiration date and today to see if it expires within 30 days
$today = date("F d, Y");
$DayDiff = abs(strtotime($AdExpirationDate) - strtotime($today));
$DaysToExpiration = floor($DayDiff / DAY);
if ($DaysToExpiration <= 30) {
$Expire30 = true;
}else{
$Expire30 = false;
}
if($Expire30) {
echo "true";
} else {
echo "false";
}
?>