zoukankan      html  css  js  c++  java
  • php获取 本月 本周 或者 下月 下周的 开始时间 结束时间

    <?php
    $now_time
    = time(); $date=date("Y-m-d",$now_time); function get_date($date,$t='d',$n=0) { if($t=='d'){ $firstday = date('Y-m-d 00:00:00',strtotime("$n day")); $lastday = date("Y-m-d 23:59:59",strtotime("$n day")); }elseif($t=='w'){ if($n!=0){$date = date('Y-m-d',strtotime("$n week"));} $lastday = date("Y-m-d 00:00:00",strtotime("$date Sunday")); $firstday = date("Y-m-d 23:59:59",strtotime("$lastday -6 days")); }elseif($t=='m'){ if($n!=0){$date = date('Y-m-d',strtotime("$n months"));} $firstday = date("Y-m-01 00:00:00",strtotime($date)); $lastday = date("Y-m-d 23:59:59",strtotime("$firstday +1 month -1 day")); } return array($firstday,$lastday); } $day1 = get_date($date,'d'); $day2 = get_date($date,'d',-1); $week1 = get_date($date,'w'); $week2 = get_date($date,'w',-1); $month1 = get_date($date,'m'); $month2 = get_date($date,'m',-1); echo '<pre>'; print_r($day1);//今天 print_r($day2);//昨天 print_r($week1);//这周 print_r($week2);//上周 print_r($month1);//这月 print_r($month2);//上月 echo '</pre>';
  • 相关阅读:
    ps怎么撤销的三种方法和ps撤销快捷键以及连续撤销多步快捷键
    jquery data()
    jQuery.extend方法
    Bootstrap
    骚操作
    mysql作业
    jQuery UI练习
    左侧菜单,表格,认证登录作业
    JS
    js中的DOM操作汇总
  • 原文地址:https://www.cnblogs.com/wlgaojin/p/3270266.html
Copyright © 2011-2022 走看看