function is_leapyear($ts) {
return (date('L', $ts) == '1');
}
$year_2016 = is_leapyear(strtotime('2016-1-1')); // returns TRUE
$year_2018 = is_leapyear(strtotime('2018-1-1')); // returns FALSE
$now = time();
$exp = strtotime('2018-4 first day of next month midnight');
if ($exp < $now) {
echo("<p>Your card has expired</p>");
} else {
echo("<p>Your card has notbexpired</p>");
}
Your card has expired
$now = time();
$exp = '04/2018'; // Change exp format from mm/yyyy to yyyy-mm
$month = substr($exp, 0, 2);
$year = substr($exp, 3, 4);
$exp = $year . '-' . $month; // Set expiration date and calculate the number of days from current date
$exp = strtotime($exp . ' first day of next month midnight');
$days = floor(($exp - $now) / 86400); // There are 86400 seconds/day
// Display a message
if ($days < 0) {
echo('<p>Your card expired ' . abs($days) . ' days ago.<br />');
} else if ($days > 0) {
echo('Your card expires in ' . $days . ' days.<br />');
} else {
echo('Your card expires at midnight.
');
}
Your card expired 2606 days ago.
$now = time();
$new_year = strtotime('next year Jan 1st', $now); // Calculate the days, hours, minutes, and seconds
$seconds = $new_year - $now;
$days = floor($seconds / 86400);
$seconds -= $days * 86400;
$hours = floor($seconds / 3600);
$seconds -= $hours * 3600;
$minutes = floor($seconds / 60);
$seconds -= $minutes * 60;
// Display the countdown
echo("<p>$days days and $hours:$minutes:$seconds remaining to the New Year.</p>");
196 days and 9:5:27 remaining to the New Year.