Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dead23angel/6517611aecc9ec71547fd893228d6d80 to your computer and use it in GitHub Desktop.
Save dead23angel/6517611aecc9ec71547fd893228d6d80 to your computer and use it in GitHub Desktop.
PHP вычислить возраст по дате рождения.
function calculate_age($birthday) {
$birthday_timestamp = strtotime($birthday);
$age = date('Y') - date('Y', $birthday_timestamp);
if (date('md', $birthday_timestamp) > date('md')) {
$age--;
}
return $age;
}
//вызов функции
echo calculate_age('1990-01-01');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment