Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
XML
<html>
<?php
error_reporting(0);
        $date=time();

        $day=date('d',$date); // current day in number.
        $month=date('m',$date); // current month in number.
        $year=date('Y',$date); // current year in number.

        $currentTimeStamp= strtotime("$year-$month-$day");
        $monthName  = date("F", $currentTimeStamp); // Get Current Month Name.
        $numDays = date("t",$currentTimeStamp); // Get how many days are there in the current month.
?>

<?php
        if(isset($_GET['p']))
        {

                $month=$month-1;
                $currentTimeStamp= strtotime("$year-$month-$day");
                $monthName  = date("F", $currentTimeStamp);
        }
        else if (isset($_GET['q']))
        {

                $month=$month+1;
                $currentTimeStamp= strtotime("$year-$month-$day");
                $monthName  = date("F", $currentTimeStamp);
        }
?>

    <table>
        <tr>
            <td>
                    <td>
                    <?php
                        echo "<a href='cal.php?p=$month'> << </a>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                    ?>
                    </td>

                    <th> <?php echo $monthName.", ".$year."  "; ?> </th>


                    <td colspan=5 align="left">
                    <?php
                        echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <a href='cal.php?q=$month'> >> </a>
                        ";
                    ?>
            </td>
        </tr>
    </table>

</html>
Posted
Comments
Member 11930850 6-Oct-15 11:20am    
Steps: If you do not understand the problem, then copy the code and paste it in any editor (like: edit plus) and save it in localhost. Open it in any browser.

Issue: If "October, 2015" is appearing and you click on previous button it shows "September, 2015" but when you clic on "next" button it shows "November, 2015" instead of "October,2015". Also it only moves a month behind or forward.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900