I was going to see if the forum could help me with this, but I managed to figure it out. Criticism invited.
<?php
$_POST['CCMonth']="10"; // change as needed to test this code
$_POST['CCYear']="10"; // change as needed to test this code
extract($_POST);
print "Input for CC Exp. is ".$CCMonth."/?/20".$CCYear."<br />";
$Today=date('m/d/Y');
print "Today is ".$Today."<br />";
$today=strtotime($Today);
if (($CCMonth=="01")||($CCMonth=="03")||($CCMonth=="05")||($CCMonth=="07")||($CCMonth=="08")||($CCMonth=="10")||($CCMonth=="12")){
$strDate = date("m/d/20y", mktime(0, 0, 0, $CCMonth, 31, $CCYear));
};
if (($CCMonth=="04")||($CCMonth=="06")||($CCMonth=="09")||($CCMonth=="11")){
$strDate = date("m/d/20y", mktime(0, 0, 0, $CCMonth, 30, $CCYear));
};
if (($CCMonth=="02")&&(date('L', strtotime("20".$CCYear."-01-01"))==0)){
$strDate = date("m/d/20y", mktime(0, 0, 0, $CCMonth, 28, $CCYear));
};
if (($CCMonth=="02")&&(date('L', strtotime("20".$CCYear."-01-01"))!=0)){
$strDate = date("m/d/20y", mktime(0, 0, 0, $CCMonth, 29, $CCYear));
};
print "CC Exp. interpreted as ".$strDate."<br />";
$strDate = strtotime($strDate);
print "CC Exp. PHP strtotime is ".$strDate."<br />";
print "Today’s date PHP strtotime is ".$today.".";
if ($strDate < $today){
$errors=1;
$error.="<li>Credit card has expired </li>";
}
if ($errors=1){
print "<ul>".$error."</ul>";
}
?>
Remove the various “print” commands, which are there only for testing, & adapt to suit your needs.