0

I have a question hw can i ad 18 years to the folowing date

$rowy_geboorte_datum = new DateTime($rowy['geboortedatum']);
$geb_dat_echtgenote = date_format($rowy_geboorte_datum, 'd-m-Y');

$rowy['geboortedatum'] is from a mysql data table and could even before 1902 as example 1820-06-10

thanks in advice John

2
Contributors
6
Replies
10
Views
3 Years
Discussion Span
Last Post by mmcdonald
0

I now that but as i mention it must work even for dates before 1970 and 1902
the link you give me is for dates after 1970

0

Then your code should work entirely with the datetime class as this isn't limited on date: http://php.net/manual/en/class.datetime.php (I believe you already were, apologies for overlooking the obvious mate!)

$date = new DateTime('1920-01-01');
$date->modify('+18 years');
echo $date->format('Y-m-d');

//Outputs: 1938-01-01

I believe that will do the job? (Untested!)

Edited by mmcdonald

0

thanks.
i tried that before too but it did not working and now it is working
Maybee i had a mistype.

Thanks for the help

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.