PHP

Calculate age – PHP

Let’s see how we can calculate person age when we have his/her birthday available:

1
2
3
function calculateAge($birthdate) {
    return floor(abs(strtotime('now') - strtotime($birthdate))/31536000);
}

Example:

echo 'Age: ' . calculateAge('15-04-1980');

Prints 31