I am working on task in which dates are involved. I have a person’s age in months+days. Now I want to get a date when this person reach to a specific age in months.
For example:
A person is 250 months and 15 days old on 2010-1-25.
On which date this person will become 300 months old?
Function Signature may be:
function getReqDate( $startDate, $currAgeMonths, $currAgeDays, $reqAgeMonths ) {
//return date
}
Since you calculate the current age from the birthdate, I suggest you also use the birthdate instead of the current age to calculate when a user gets 300 months old. The following is the equivalent of the DateTime solution given above (does not require 5.3):
With the second param being the birthdate timestamp the above would give
Further reading: