I have an end date and a start date, which is six days lower than the start date. i.e:
$ExpDate = (explode("-",$ReportDate));
$EndMonth = $ExpDate;
$EndDay = $ExpDate;
$EndYear = $ExpDate;
$ShortYear = $EndYear;
if($EndYear<2000) $EndYear = $EndYear + 2000;
if(strlen($EndMonth) < 2) $EndMonth = "0" . $EndMonth;
if(strlen($EndDay) < 2) $EndDay = "0" . $EndDate;
$EndDate = $EndYear . '-' . $EndMonth . '-' . $EndDay;
$StartMonth = $EndMonth;
$StartDay = $EndDay - 6;
This works fine until $StartDay is less than 1. Then I have:
if ($StartDay < 1)
$StartMonth = $StartMonth - 1;
$num = cal_days_in_month(CAL_GREGORIAN, $StartMonth, $StartYear);
$StartDay = $num + $StartDay;
All totaled, I have 6 'if' statements to manipulate the day month and year. I have also tried various and sundry manipulations of the date-time stamp and still need all the 'if' statements.
I do not understand the '$strtotime' function well enough to get the desired outcome.
So how can I get from '8-4-12' - 6 days = 2012-07-29 ? Is there a way to do this without all the math?
Could someone point me in the right direction?