RE: [Updated] Previous and Next Month and Year

From: Date: Tue, 19 Jun 2007 03:36:48 +0000
Subject: RE: [Updated] Previous and Next Month and Year
Groups: php.general 
Request: Send a blank email to php-general+get-257365@lists.php.net to get a copy of this message
Hi Guys, RE: [Updated] Previous and Next Month and Year Here is part of my code: $month = 6; // Current month value, but changes changes with next/prev links. // Value used by a mini calendar script "phpcalendar"... // Originally derived via: $month = date('n', time()); // And updated with $month = $month +1 for next month // And $month = $month -1 for next month // So the value will be 1 through 12 for current year's months. // And 0, -1, -2 etc. for last year and 13, 14 etc. for next year. $prev_month = date('F Y', mktime(0, 0, 0, date("m")-$month, date("d"), date("Y"))); $next_month = date('F Y', mktime(0, 0, 0, date("m")+$month, date("d"), date("Y"))); echo "Month: $month <br /> \n"; echo "Prev: $prev_month <br /> \n"; echo "Next: $next_month <br /> \n"; The result: Month: 6 Prev: December 2006 Next: December 2007 The desired results would be: Month: 6 Prev: May 2007 Next: July 2007 And needs to bear in mind the year... The phpcalendar script is working perfectly with my own next and prev month links using $month +1 and $month -1. So I am trying to get my Event boxes to work in the same way listing the previous month, current month and next month. Thanks, Keith

« previous php.general (#257365) next »