如何增加单击下一个和上一个按钮的时间戳 [英] How to increase timestamp on clicking next and previous buttons

查看:74
本文介绍了如何增加单击下一个和上一个按钮的时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是PHP的新手。我已经编写了一个代码来增加和减少月份和年份点击下一个和上一个按钮,但它不起作用。请帮忙。代码如下。你可以在localhost中运行它。只需单击下一个和上一个按钮,然后观察问题。如果您不明白,请发表评论。



代码:





I am new to PHP. I have written a code to increase and decrease month and year on clicking next and previous buttons but it does not work accordingly. Please help. Code is given below. you can run it in your localhost. Just click on next and previous button and observe the issue. If you don't understand, give a comment.

Code:


<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>

推荐答案

date = time();



date=time();


day = date(' d',
day=date('d',


date ); // 当前 day 麻木呃。

date); // current day in number.


这篇关于如何增加单击下一个和上一个按钮的时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆