Jump to content

Age Validation


jp555soul

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.