Hi,
Sunday, June 17, 2007, 3:54:01 PM, you wrote:
KS> Hi,
KS> RE: Previous and Next Month and Year
KS> This is my code:
KS> $next_month = date('F Y', time()+$month);
KS> $prev_month = date('F Y', time()-$month);
KS> echo "$prev_month <br /> \n"; #Result "June 2007"
KS> echo "$next_month <br /> \n"; #Result "June 2007"
KS> What I am trying to do is get the month and year
KS> based upon a + or - $month value.
KS> The variable $month being "6" for the month of June of
KS> the present year of 2007.
KS> For example ($month -7) would be December 2006,
KS> and ($month +7) would be January 2006.
KS> Please help... Thank you.
KS> Keith
$now = strtotime(date('Y-m-15'));
$current = date('F',$now);
$last = date('F', strtotime('-1 month', $now));
$next = date('F',strtotime('+1 month', $now));
echo "Current:$current Previous:$last Next:$next\n";
--
regards,
Tom
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php