Created
January 29, 2018 14:14
-
-
Save Padilo300/6a8b645523b791b66a2d983f1b2a8bb6 to your computer and use it in GitHub Desktop.
PHP вычислить возраст по дате рождения.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
AlexeyMazheykin
commented
Jul 15, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment