- $month = date('m/Y', strtotime('-'.$m.' month'));
- $month_start = date('Y-m', strtotime('-'.$m.' month')); $month_start .= "-01";
- $month_end = date('Y-m', strtotime('-'.$m.' month')); $month_end .= "-31";
+ 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";