zoukankan      html  css  js  c++  java
  • 时间

    // 当月开始时间结束时间
    $this_month_start = strtotime(date('Y-m-d H:i:s', strtotime("first day of this month 00:00:00")));
    $this_month_end   = strtotime(date('Y-m-d H:i:s', strtotime("last day of this month 23:59:59")));
    
    //php获取前一个小时的时间:
    
    $mtime= date("Y-m-d H:i:s", strtotime("-1 hour"));
    //php获取前一天的时间:
    
    $mtime= date("Y-m-d H:i:s", strtotime("-1 day"));
    //php获取三天前的时间:
    
    $mtime= date("Y-m-d H:i:s", strtotime("-3 day"));
    //php获取前一个月的时间:
    
    $mtime= date("Y-m-d H:i:s", strtotime("-1 month"));
    //php获取三个月前的时间:
    
    $mtime= date("Y-m-d H:i:s", strtotime("-3 month"));
    //php获取前一年的时间:
    
    $mtime= date("Y-m-d H:i:s", strtotime("-1 year"));
    
    //php获取今日开始时间戳和结束时间戳
    $today_start=mktime(0,0,0,date('m'),date('d'),date('Y'));
    $today_end=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
    
    //php获取昨日起始时间戳和结束时间戳
    $yesterday_start=mktime(0,0,0,date('m'),date('d')-1,date('Y'));
    $yesterday_end=mktime(0,0,0,date('m'),date('d'),date('Y'))-1;
    
    //php获取上周起始时间戳和结束时间戳
    $lastweek_start=mktime(0,0,0,date('m'),date('d')-date('w')+1-7,date('Y'));
    $lastweek_end=mktime(23,59,59,date('m'),date('d')-date('w')+7-7,date('Y'));
    
    //php获取本周周起始时间戳和结束时间戳
    $thisweek_start=mktime(0,0,0,date('m'),date('d')-date('w')+1,date('Y'));
    $thisweek_end=mktime(23,59,59,date('m'),date('d')-date('w')+7,date('Y'));
    
    //php获取本月起始时间戳和结束时间戳
    $thismonth_start=mktime(0,0,0,date('m'),1,date('Y'));
    $thismonth_end=mktime(23,59,59,date('m'),date('t'),date('Y'));
    
    //今天
    $today = date("Y-m-d");
    $today_begin = date('Y-m-d 00:00:00');
    $today_end = date('Y-m-d 23:59:59');
    //昨天
    $yesterday = date("Y-m-d", strtotime(date("Y-m-d"))-86400);
    //上周
    $lastweek_start = date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),date("d")-date("N")+1-7,date("Y")));
    $lastweek_end = date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("d")-date("N")+7-7,date("Y")));
    //本周
    $thisweek_start = date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),date("d")-date("N")+1,date("Y"))); 
    $thisweek_end = date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("d")-date("N")+7,date("Y"))); 
    //上月
    $lastmonth_start = date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m")-1,1,date("Y"))); 
    $lastmonth_end = date("Y-m-d H:i:s",mktime(23,59,59,date("m") ,0,date("Y"))); 
    //本月
    $thismonth_start = date('Y-m-01 00:00:00');
    $thismonth_end = date('Y-m-t 23:59:59'); 
    //本季度未最后一月天数 
    $getMonthDays = date("t",mktime(0, 0 , 0,date('n')+(date('n')-1)%3,1,date("Y")));
    //本季度/
    $thisquarter_start = date('Y-m-d H:i:s', mktime(0, 0, 0,date('n')-(date('n')-1)%3,1,date('Y'))); 
    $thisquarter_end = date('Y-m-d H:i:s', mktime(23,59,59,date('n')+(date('n')-1)%3,$getMonthDays,date('Y')));
     
    //2016-08-10这天 2个月后的日期
    echo date("Y-m-d",strtotime("+2 month",strtotime("2016-08-10")));
         
    //当前 3个月后的日期
    echo date("Y-m-d",strtotime("+3 month",time()));
    
    //n月前开始结束时间
    $last_nmonth_start = date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m")-n,1,date("Y"))); 
    $last_nmonth_end = date("Y-m-d H:i:s",mktime(23,59,59,date("m")-(n-1) ,0,date("Y")));
    /**下月开始时间结束时间 */
    $next_nmonth_start = date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m")+1,1,date("Y")));
    $next_nmonth_end = date("Y-m-d H:i:s",mktime(23,59,59,date("m")+2,0,date("Y")));
    
    
    //获取当天0点的时间戳
    	$begintime = strtotime($data['time']);
    	//获取当天24点的时间戳
    	$endtime = strtotime($data['time']) + 86399;
    	
    $date = '20210215';
    //指定时间的月初		
    $firstday = date("Y-m-01 00:00:00",strtotime($date)); 
    //指定时间的月末
    $lastday = date("Y-m-d 23:59:59",strtotime("$firstday +1 month -1 day"));  //月末
    
    $date = '20210215';
    //指定时间的月初		
    $firstday = date("Y-m-01 00:00:00",strtotime($date)); 
    //指定时间的月末
    $n = 3;
    $lastday = date("Y-m-d 23:59:59",strtotime("$firstday +$n month -1 day"));  //月末
    
    //指定时间的上月初上月末
    $last_month_firstday = date("Y-m-01",strtotime("$date-1 month ")); 
    $last_month_lastday = date("Y-m-d",strtotime("$last_month_firstday +1 month -1 day"));
    //指定时间的下月初下月末
    $next_month_firstday = date("Y-m-01 00:00:00",strtotime("$date+1 month ")); 
    $next_month_lastday = date("Y-m-d 23:59:59",strtotime("$next_month_firstday +1 month -1 day"));
    
  • 相关阅读:
    Tomcat6 一些调优设置内存和连接数
    【原创】使用c3p0数据库连接池时出现com.mchange.v2.resourcepool.TimeoutException
    JVM内存的设置
    JBOSS以及tomcat最大连接数配置和jvm内存配置
    摘抄python __init__
    Python中__init__方法介绍
    Python 绝对简明手册
    python中eval, exec, execfile,和compile [转载]
    extern、static、auto、register 定义变量的不同用法
    Python 网络编程说明
  • 原文地址:https://www.cnblogs.com/jigr/p/15009388.html
Copyright © 2011-2022 走看看