In PHP given a UTC timestamp I would like to add exactly N number of years. This should take into consideration leap years.
Thank you.
In PHP given a UTC timestamp I would like to add exactly N number of years. This should take into consideration leap years.
Thank you.
echos
adds 10 years (
10Y
) to "today". DateTime's only in PHP 5.3, though.Replace "+2 years" as required.
ref: http://php.net/manual/en/function.strtotime.php
One thing you should consider when you do this.
This adds up 2 years ( 720 or 721 days). In case you just want to keep the same day and month and add 2 extra years in the timestamp
you have to use mktime.
Example