jp555soul Posted December 10, 2010 Share Posted December 10, 2010 So Im in the weird place where my age validation is not working, any ideas: $dob = strtotime($_POST['dob']); //855993600 Feb 15th 1997 $age_req = strtotime('-13 year', $dob); //445680000 Feb 15th 1984 $time = time(); //1292007621 if ($time < $age_req){} Link to comment https://forums.phpfreaks.com/topic/221241-age-validation/ Share on other sites More sharing options...
litebearer Posted December 10, 2010 Share Posted December 10, 2010 Presuming you are checking to see if someone is over/under a certain age requirement, this will give you their age in years. Then simply do your comparison. <?php $ageTime = strtotime($_POST['dob']); // Get the person's birthday timestamp $t = time(); // Store current time for consistency $age = ($ageTime < 0) ? ( $t + ($ageTime * -1) ) : $t - $ageTime; $year = 60 * 60 * 24 * 365; $ageYears = $age / $year; ?> Link to comment https://forums.phpfreaks.com/topic/221241-age-validation/#findComment-1145497 Share on other sites More sharing options...
jp555soul Posted December 10, 2010 Author Share Posted December 10, 2010 I need to compare the age requirement to the dob not the date. Link to comment https://forums.phpfreaks.com/topic/221241-age-validation/#findComment-1145499 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.