dvm/func_age.php
2022-11-28 10:27:30 +01:00

15 lines
589 B
PHP
Executable File

<?php
function ifAge ($check){
if (!preg_match ("%(\d{1,2}.\d{1,2}.\d{2,4})\s*([<>=]{1,2})\s*(\d+)%", $check, $check))
return false;
$date = explode (".", $check[1]);
$date = mktime (0, 0, 0, $date[1], $date[0], $date[2]);
$date = strtotime ("+ $check[3] years", $date);
eval ("\$value = (" . time() . " $check[2] $date);");
return $value;
}
# echo (int) ifAge ("29.01.2002 > 18");
# Ausgabe 0, nicht volljährig; Ausgabe 1, volljährig
?>