ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

时间

2021-07-14 11:01:40  阅读:230  来源: 互联网

标签:59 start strtotime mktime 时间 date end


// 当月开始时间结束时间
$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")));

标签:59,start,strtotime,mktime,时间,date,end
来源: https://www.cnblogs.com/jigr/p/15009388.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有