Just wondering, can I do this to validate that a user has entered a date over 18?
//Validate for users over 18 only
function time($then, $min)
{
$then =
Here is a simplified extract from what I used for a banking system in Toronto, and this always worked perfectly, taking account of leap years of 366 days.
/* $dob is date of birth in format 1980-02-21 or 21 Feb 1980
* time() is current server unixtime
* We convert $dob into unixtime, add 18 years, and check it against server's
* current time to validate age of under 18
*/
if (time() < strtotime('+18 years', strtotime($dob))) {
echo 'Client is under 18 years of age.';
exit;
}