PHP Calculate Age
This is the simplest way I could devise to calculate a person's age. Basically I calculate the input variable and use strtotime() to convert it to a timestamp. I chose this method to give the most flexibility in the input. Then I simply calculate the difference in seconds and divide that by the number of seconds in a year. You should probably add some validation to be sure the input date is before today, but again, this is quick and dirty.
Home | PHP | PHP Calculate Age
You’re currently reading “ PHP Calculate Age ,” an entry on BRADINO
- Published:
- 11.6.07 / 5pm
- Category:
- PHP












