stevesimo Posted April 18, 2007 Share Posted April 18, 2007 Hi, I am trying to validate whether or not a date of birth entered in dd/mm/yyyy format is between 16 and 69 years old. Suppose we have todaysdate = 18/04/2007 The minimum allowed date of birth would be 18/04/1991 and the maximum allowed date of birth would be 18/04/1938. I have looked at using strtotime but this only does dates from 1970 (I think) Can anyone help me with this as I am really stuck and not sure how to compare the dates. Thanks Steve (Blackpool) Quote Link to comment Share on other sites More sharing options...
Orio Posted April 18, 2007 Share Posted April 18, 2007 <?php list($d, $m, $y) = explode("/", $date); $time = mktime(0, 0, 0, $m, $d, $y); $age = floor((now() - $time) / 31557600); //This number is the number of secs in a year if($age < 69 && $age > 16) echo "Good age!"; else echo "Bad age!"; ?> Orio. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.