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 = strtotime('March 23, 1988');
//The age to be over, over +18
$min = strtotime('+18 years', $then);
echo $min;
if (time() < $min) {
die('Not 18');
}
}
Just stumbled across this function date_diff:
http://www.php.net/manual/en/function.date-diff.php
Looks, even more promising.
Why not? The only problem to me, is the User Interface – how you send out the error message elegantly to the user.
On another note, your function might not work properly as you did not intake a proper birthday (you are using a fixed birthday). You should change ‘March 23, 1988’ to $then
Or you can: