Tuesday, February 26, 2013

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