php validate credit card expiration date code example
Example 1: php check credit card expiration
$expires = DateTime::createFromFormat('my', $_POST['expMonth'].$_POST['expYear']);
$now = new DateTime();
if ($expires < $now) {
echo 'Expired!';
}
Example 2: php validate credit card expiration date
$expires = date_format( \DateTime::createFromFormat('ym', $cc_expiration),"ym");
$now = date_format(new \DateTime(),"ym");
if ($expires < $now) {
return 'Expired!';
}