Jump to content

[SOLVED] Calculating Dates


gabrielp

Recommended Posts

Do it like this:

 

$start='2008-01-11 06:38:44'
$months_to_add=13;
$qty_years=floor($months_to_add/12);
$qty_months=$months_to_add%12;
$bits=explode("-",$start);
$year=$bits[0]
$month=$bits[1];
$newyear=$year+$qty_years;
$newmonth=$month+$qty_months;

$newdate=$newyear."-".$newmonth."-".$bits[2];

 

That's probably not the best way of doing it, but it should work. I'm assuming that your date format is YYYY-MM-DD, not YYYY-DD-MM.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.