From: Alan Jack Pippin Date: Sun, 1 Jan 2006 05:47:50 +0000 (-0700) Subject: Compensated for bug in php strtotime() function related to months with 31 days. X-Git-Tag: release_0_1_0~70 X-Git-Url: http://git.pippins.net/embedvideo/.git/%7Bnolink%7D?a=commitdiff_plain;h=525cd8ffa4cd9ccd70b524e54dddd8a610371284;p=eq%2F.git Compensated for bug in php strtotime() function related to months with 31 days. --- diff --git a/inc/class.eq.inc.php b/inc/class.eq.inc.php index 9e6f8e2..a20f156 100644 --- a/inc/class.eq.inc.php +++ b/inc/class.eq.inc.php @@ -217,9 +217,10 @@ class eq // in the past $num_months for this Family $header_row="Families"; for($m=$num_months; $m >= 0; $m--) { - $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"; $sql = "SELECT * FROM eq_visit WHERE date >= '$month_start' AND date <= '$month_end' ". " AND companionship=" . $unique_companionships[$j]['companionship']. " AND family=". $family_id; @@ -931,9 +932,10 @@ class eq $header_row .= "$year"; } else { - $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"; $sql = "SELECT * FROM eq_ppi WHERE date >= '$month_start' AND date <= '$month_end' ". "AND elder=" . $elder_id . " AND eqpresppi=0"; $this->db2->query($sql,__LINE__,__FILE__);