function age($dob) {
// Seconds in a year
$seconds = 31556926;
// Calc. age based on the provided date_of_birth val
$age = floor((time() - strtotime($dob)) / $seconds);
return $age;
}
by Valeri Tandilashvili
4 years ago
PHP
1
Pro tip: use ```triple backticks around text``` to write in code fences