I want to check whether the current year is greater than a date string(D-M-Y) here is my code
$OldDate = "09-30-2011";
$OldYear = strtok($OldDate, '-');
$NewYear = date("Y");
if ($OldYear < $NewYear) {
echo "Year is less than current year"
} else {
echo "Year is greater than current year";
}
You can use
strtotime():UPDATE
Because you’re using an unconventional datestamp, you have to use different methods, eg:
NOTE: If you want to always be sure that your date gets correctly understood by
strtotime, use YYYY-MM-DD