Re: In case this helps... (Calendar Date Help)
| From: | Mark Weaver | Date: | Wed, 28 May 2008 21:26:25 +0000 |
| Subject: | Re: In case this helps... (Calendar Date Help) | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-274786@lists.php.net to get a copy of this message | ||
Robert Cummings wrote:
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 ) ); echo '<a href="?date='.date( 'Y-m', $timestampPrev ).'">Prev</a><br />'; echo '<a href="?date='.date( 'Y-m', $timestampCurr ).'">Curr</a><br />'; echo '<a href="?date='.date( 'Y-m', $timestampNext ).'">Next</a><br />'; ?>Well, of course it's sloppy. I've only been coding PHP OOP since January. :) Given the app is barely in the alpha stage I wanted to start with a simple premise and wait till development is further along to make the ugly bits more elegant. At the moment I don't understand why getStamp() isn't taking $dateStr and returning the the {year} for date stamps in past or future outside the current year. (value being passed to getStamp() inside $dateStr is 'date('Y')-1') When I can understand what I'm currently doing wrong premise changing will likely make a lot more sense. -- 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)