Skip to content
Advertisement

PHP calculate age

I’m looking for a way to calculate the age of a person, given their DOB in the format dd/mm/yyyy.

I was using the following function which worked fine for several months until some kind of glitch caused the while loop to never end and grind the entire site to a halt. Since there are almost 100,000 DOBs going through this function several times a day, it’s hard to pin down what was causing this.

Does anyone have a more reliable way of calculating the age?

JavaScript

EDIT: this function seems to work OK some of the time, but returns “40” for a DOB of 14/09/1986

JavaScript

Advertisement

Answer

This works fine.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement