im struggling to write a script that accepts a standard DoB converts it to UNIX format and calculates the age of the person in years to a decimal precision of one point. the orginal dob format is DD/MM/YY any help is appreciated
a solution will be : #reformat date as MM/DD/YY $dob = "19/04/76"; $od = split("/", $dob); $nd = "{$od[1]}/{$od[0]}/{$od[2]}"; # calculate $old_y = (time() - strtotime($nd)) / (365 * 24 * 3600); echo number_format($old_y,1); PHP: hope this helps
The function only works between a certain date range, i.e it wont give me the correct age for people born in <1946
yes, because time() has a reference point in january 1st 1970 as stated in php manual: so, you will see weird results on dates < 1970 you have to use another algorithm for your calculations.