- if(`date '+%d'` == 31) { $d = 1; } else { $d = 0; }
- $month = date('m/Y', strtotime('-'.$m.' month -'.$d.' day'));
- $month_start = date('Y-m', strtotime('-'.$m.' month -'.$d.' day')); $month_start .= "-01";
- $month_end = date('Y-m', strtotime('-'.$m.' month -'.$d.' day')); $month_end .= "-31";
+ $month = $this->current_month - $m;
+ $year = $this->current_year;
+ if($month <= 0) { $remainder = $month; $month = 12 + $remainder; $year=$year-1; }
+ if($month < 10) { $month = "0"."$month"; }
+ $month_start = "$year"."-"."$month"."-"."01";
+ $month_end = "$year"."-"."$month"."-"."31";
+ $month = "$month"."/"."$year";
+ //print "m: $m month: $month year: $year month_start: $month_start month_end: $month_end<br>";