Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $birthday = '1985-04-15'; //Дата рождения
- $age = floor( ( time() - strtotime($birthday) ) / (60 * 60 * 24 * 365.25) ); //Формула
- echo $age; //27
- function getAge($birthdate, $ageTime = null/*now by default*/){
- return (new DateTime())
- ->setTimestamp($ageTime ? $ageTime : time())
- ->diff(new DateTime($birthdate))->format('%Y');
- }
Add Comment
Please, Sign In to add comment