Checking if a UK date is in the past with PHP
The easiest way to check if a date is in the past with PHP is using strtotime but unfortunately it only understands US and Unix date formats, not the UK’s format d/m/Y.
A UK date string therefore needs to be transformed first. You will need to use a regular expression to first validate that your UK date is valid. I do not set this out here. Once you are sure you have a UK valid date string of the format d/m/Y, e.g. 01/02/2010 you can do the following:
// tests a uk date string for being in the past. time components will be midnight for test to work.
function is_uk_date_in_past($pre_validated_uk_date_string_no_time) {
list($d, $m, $y) = explode('/', $pre_validated_uk_date_string_no_time);
$today = strtotime(date("Y-m-d")); // we do not define today as time() as that will include the current time
$given = strtotime("{$y}-{$m}-{$d}");
return $given >= $today;
}