• 用php获取本周,上周,本月,上月,本季度日期的代码


     1 echo date("Ymd",strtotime("now")), "
    ";
     2 echo date("Ymd",strtotime("-1 week Monday")), "
    ";
     3 echo date("Ymd",strtotime("-1 week Sunday")), "
    ";
     4 echo date("Ymd",strtotime("+0 week Monday")), "
    ";
     5 echo date("Ymd",strtotime("+0 week Sunday")), "
    ";
     6  
     7  
     8 //date('n') 第几个月
     9 //date("w") 本周周几
    10 //date("t") 本月天数
    11  
    12 echo '<br>上周:<br>';
    13 echo date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),date("d")-date("w")+1-7,date("Y"))),"
    ";
    14 echo date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("d")-date("w")+7-7,date("Y"))),"
    ";
    15 echo '<br>本周:<br>';
    16 echo date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y"))),"
    ";
    17 echo date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y"))),"
    ";
    18  
    19 echo '<br>上月:<br>';
    20 echo date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m")-1,1,date("Y"))),"
    ";
    21 echo date("Y-m-d H:i:s",mktime(23,59,59,date("m") ,0,date("Y"))),"
    ";
    22 echo '<br>本月:<br>';
    23 echo date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),1,date("Y"))),"
    ";
    24 echo date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("t"),date("Y"))),"
    ";
    25  
    26 $getMonthDays = date("t",mktime(0, 0 , 0,date('n')+(date('n')-1)%3,1,date("Y")));//本季度未最后一月天数
    27 echo '<br>本季度:<br>';
    28 echo date('Y-m-d H:i:s', mktime(0, 0, 0,date('n')-(date('n')-1)%3,1,date('Y'))),"
    ";
    29 echo date('Y-m-d H:i:s', mktime(23,59,59,date('n')+(date('n')-1)%3,$getMonthDays,date('Y'))),"
    ";

    转自:http://www.cnblogs.com/whlives/p/5795458.html

  • 相关阅读:
    ReactJS入门学习一
    js控制html5 【video】标签中视频的播放和停止
    CentOS中vsftp安装与配置
    linux 添加多个网段
    js图片预加载后触发操作
    nodejs在后台运行
    asp.net环境搭建
    aspx aspx.cs
    linux 添加静态ip dns
    kali ssh服务开启登录
  • 原文地址:https://www.cnblogs.com/ygcool/p/6697562.html
Copyright © 2020-2023  润新知