[solved] Previous/Next month driving me round the bend
Posted: Tue Feb 27, 2007 3:56 pm
I have been fiddling with date and time functions ready to have a go at a calendar.
I can't seem to get the previous/next links below to role round the years at Jan and Dec.
In other words...The months roll forwards and backwards, but not the year!
What am I doing wrong please?
I can't seem to get the previous/next links below to role round the years at Jan and Dec.
In other words...The months roll forwards and backwards, but not the year!
What am I doing wrong please?
Code: Select all
<?php
// Today's month
$m=date("m");
//if previous or next press then used that value for the "current" month
if (isset($_REQUEST['m'])){
$m=date("m",intval($_REQUEST['m']));
}
// timestamps
$current = mktime(0, 0, 0, $m);
$next = mktime(0, 0, 0, $m+1);
$previous = mktime(0, 0, 0, $m-1);
// so I can read it!
$now=date("d M Y",$current);
//The links
echo "<a href=\"test.php?m=$previous\">Previous</a>Current month selected $now <a href=\"test.php?m=$next\">Next</a>";
?>