Re: In case this helps... (Calendar Date Help)
| From: | Mark Weaver | Date: | Wed, 28 May 2008 21:40:15 +0000 |
| Subject: | Re: In case this helps... (Calendar Date Help) | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-274787@lists.php.net to get a copy of this message | ||
Robert Cummings wrote:
On Wed, 2008-05-28 at 16:47 -0400, Robert Cummings wrote:Ok... I've made a change to getStamp() using the two lines above to see what would happen, however the results are the same. If I move through the months up to December the calendar moves normally and correctly. But, once I get to January it displays January for 2008 and never increments the year. getStamp() now looks like this: public function getStamp($stamp,$d){ if ($d === 1){ return strtotime( '+1 month', $stamp ); } elseif($d === 0){ return strtotime( '-1 month', $stamp ); } } I know it's a matter of me not understanding fully what I'm doing; I'm just not sure where to go from here. -- Mark ------------------------- the rule of law is good, however the rule of tyrants just plain sucks! Real Tax Reform begins with getting rid of the IRS. ============================================== Powered by CentOS5 (RHEL5)Out of curiosity.. have you thought about reworking your premise? Using prev, current, and next is extremely sloppy IMHO. Additionally, it prevents bookmarking a specific calendar date. Why don't you have a date parameter that indicates the year and month? If no such field exists then you fallback to current date. Then the situation becomes trivial and doesn't require dependence on the session. Having looked at your code it strikes me as very poorly thought out which makes it difficult to ascertain your current problem. At any rate, it's obviously more complex than is necessary. <?php $date = isset( $_GET['date'] ) ? $_GET['date'] : date( 'Y-m' ); list( $year, $month ) = explode( '-', $date ); $timestampCurr = mktime( 0, 0, 0, $month, 1, $year ); $timestampPrev = strtotime( '-1 month', date( 'Y-m-d', $timestamp ) ); $timestampNext = strtotime( '+1 month', date( 'Y-m-d', $timestamp ) );Those two lines above should be: $timestampPrev = strtotime( '-1 month', $timestampCurr ); $timestampNext = strtotime( '+1 month', $timestampCurr ); Cheers, Rob.