From 5b1d73d4f7ef68f26b2f51b21d06add7895702fb Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Sat, 26 Mar 2011 10:44:44 +0100 Subject: [PATCH] Fixed negative values processing in add_months() --- includes/date_functions.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/date_functions.inc b/includes/date_functions.inc index ee37f00..e4b2c76 100644 --- a/includes/date_functions.inc +++ b/includes/date_functions.inc @@ -267,9 +267,9 @@ function add_months($date, $months) // accepts negative values as well global $date_system; list($day, $month, $year) = explode_date_to_dmy($date); - $month += $months; - $year += ($month-1)/12; - $month = ($month-1)%12 + 1; + $months += $year*12+$month; + $month = ($months-1)%12+1; + $year = ($months-$month)/12; $timet = mktime(0,0,0, $month, min($day, days_in_month($month, $year)), $year); -- 2.30.2