PHP add months to date via "strtotime"

If you need a date calculation via PHP date, you would use “strtotime”. For example you have a date and you’ll need add months to it.


$start = strtotime("20-09-2012");
$months = 5;
$result = strtotime("+$months months", $start);
echo $result; // 20-02-2013

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s