PHP-Date()

  1. 输出固定时间的前一天,例如:输出2013-08-04的前一天
    <?PHP
        $ttime="2013-08-04";
         echo date("Y-m-d H:i:s",strtotime("$ttime - 1 day"));
    ?>
  2. 输出固定时间的后一天,例如:输出2013-08-04的后一天
    <?PHP
        $ttime="2013-08-04";
         echo date("Y-m-d H:i:s",strtotime("$ttime + 1 day"));
    ?>
  3. 输出这个月的第一天,例如输出8月份的第一天
    <?PHP
         echo date("Y-m-01",strtotime("now"));
    ?>
  4. 输出这个月的最后一天,例如输出8月份的最后一天
    <?PHP
          $firstday = date("Y-m-01",strtotime("now"));
          echo date("Y-m-d",strtotime("$firstday +1 month -1 day")) ;
    ?>
  5. 输出上个月的第一天,例如输出8月份的上个月的第一天<pre name="code" class="html"><?PHP
          echo date("Y-m-01",strtotime("-1 month")) ;
    ?>
     
  6. <pre name="code" class="html">输出下个月的第一天,例如输出8月份的下个月的第一天<pre name="code" class="html"><?PHP
          echo date("Y-m-01",strtotime("+1 month")) ;
    ?>
     
     
  7. <pre name="code" class="html">指定日期的时间<span>戳<span>strtotime</span></span>,即是输出一个指定的时间值:2010-07-01 08:00:00<pre name="code" class="html"><?PHP
         echo date("Y-m-d H:i:s",strtotime("2010-07-01 08:00:00")) ;
    ?>
     
     
  8. <pre name="code" class="html">明天此时的时间戳strtotime("+1 day")<pre name="code" class="html"><?PHP
         echo date("Y-m-d H:i:s",strtotime("+1 day")) ;
    ?>
     
     
  9. <pre name="code" class="html">昨天此时的时间戳strtotime("-1 day")<pre name="code" class="html"><?PHP
         echo date("Y-m-d H:i:s",strtotime("-1 day")) ;
    ?>
     
     
  10. <pre name="code" class="html">下个星期此时的时间戳strtotime("+1 week")<pre name="code" class="html"><?PHP
         echo date("Y-m-d H:i:s",strtotime("+1 week")) ;
    ?>
     
     
  11. <pre name="code" class="html">上个星期此时的时间戳strtotime("-1 week")<pre name="code" class="html"><?PHP
        echo date("Y-m-d H:i:s",strtotime("-1 week"))  ;
    ?>
     
     
  12. <pre name="code" class="html">下星期几的时间戳strtotime("next Thursday")<pre name="code" class="html"><?PHP
        echo date("Y-m-d H:i:s",strtotime("next Thursday")) ;
    ?>
     
     
  13. <pre name="code" class="html">上星期几的时间戳strtotime("last Thursday")<pre name="code" class="html"><?PHP
       echo date("Y-m-d H:i:s",strtotime("last Thursday")) ;
    ?>
     
     
  14. <pre name="code" class="html"><pre name="code" class="html">
    注:此处未说明的时间,均以当前时间:2013-08-15为准;



     
    </pre><br /><pre>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值