- date_default_timezone_set: documentation ( source)
- date: documentation ( source)
- strtotime: documentation ( source)
<?php
date_default_timezone_set('UTC');
function diff($age) {
$morgen['day'] = date('d');
$morgen['month'] = date('m');
$morgen['year'] = date('Y') - $age;
$datum = $morgen['year'] .'-' .$morgen['month'].'-' .$morgen['day'];
return $datum;
}
$minDatum = strtotime(diff(18));
$maxDatum = strtotime(diff(32));
$dob = strtotime("23-10-1989");
echo $dob."\n".$minDatum."\n".$maxDatum."\n";
if (!$dob){
//$date_of_birth = date('Y-m-d H:i:s', $minDatum);
} elseif ($dob <= $maxDatum || $dob >= $minDatum){
$date_of_birth = date('Y-m-d H:i:s', $minDatum);
}else{
$date_of_birth = date('Y-m-d H:i:s', $dob);
}
echo $date_of_birth;
?>