From: http://www.karlrixon.co.uk/writing/calculating-age-from-date-of-birth-in-php/
I imagine it’s a fairly common task to calculate an age in years from a date of birth. However most of the solutions I’ve seen either seem to be unnecessarily complicated or else fail to take in into account leap years or the current month and date as well as year. The following function is very fast and pretty simple.
It expects a date of birth in the format “DD-MM-YYYY”, however this can be modified by changing the order of the variables in the list function, for example to change to “MM-DD-YYYY” you would just edit like so:
One note to bear in mind – it is tempting to accept a string in any valid format and parse it with strtotime. This will work, but because it relies upon a Unix timestamp, it will not work for dates before 1 January 1970. If this is not an issue for you, the following function can be used instead, and saves having to massage dates into the required format beforehand: