php add 1 month to date code example

Example 1: +1 month php

$time = strtotime("2010.12.11");
$final = date("Y-m-d", strtotime("+1 month", $time));

Example 2: add 6 months to date in php

$effectiveDate = date('Y-m-d', strtotime("+3 months", strtotime($effectiveDate)));

Example 3: in date function + 1 month and - 1 day in php

echo Date("Y-m-d", strtotime("2013-01-01 +1 Month -1 Day"));// 2013-01-31

echo Date("Y-m-d", strtotime("2013-01-31 +1 Month -3 Day")); // 2013-02-28

echo Date("Y-m-d", strtotime("2013-01-31 +2 Month")); // 2013-03-31

echo Date("Y-m-d", strtotime("2013-01-31 +3 Month -1 Day")); // 2013-04-30

echo Date("Y-m-d", strtotime("2013-12-31 -1 Month -1 Day")); // 2013-11-30

echo Date("Y-m-d", strtotime("2013-12-31 -2 Month")); // 2013-10-31

echo Date("Y-m-d", strtotime("2013-12-31 -3 Month")); // 2013-10-01

echo Date("Y-m-d", strtotime("2013-12-31 -3 Month -1 Day")); // 2013-09-30

Example 4: php date today plus 1 month

$future_timestamp = strtotime("+1 month");
$data = date('Y-m-d', $future_timestamp);

Tags:

Php Example