php - comparing timestamp dates to make sure user is of minimum age

Posted by Micheal Ken on Stack Overflow See other posts from Stack Overflow or by Micheal Ken
Published on 2012-03-24T17:17:07Z Indexed on 2012/03/24 17:29 UTC
Read the original article Hit count: 275

Filed under:
|
|

When a user signs up the system has to check that they are old enough to do so, in this example they have to be atleast 8 years old

$minAge = strtotime(date("d")."-".date("m")."-".(date("Y")-8));
$dob = strtotime($day."-".$month."-".$year);

$minAge = 01-03-2004, $dob = 01-02-2011

I basically need to make sure this person was born before 2004 but I want to know whether I have to convert the timestamps to do a comparison or whether there is a more efficient way.

Any help is appreciated, thank you

© Stack Overflow or respective owner

Related posts about php

Related posts about date