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; //获取昨日起始时间戳和结束时间戳 $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; //获取上周起始时间戳和结束时间戳 $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')); //获取本周周起始时间戳和结束时间戳 $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')); //获取本月起始时间戳和结束时间戳 $thismonth_start=mktime(0,0,0,date('m'),1,date('Y')); $thismonth_end=mktime(23,59,59,date('m'),date('t'),date('Y'));

 


根据页面传过来的值获取某个时间段的时间戳
$month = empty($_REQUEST["month"]) ? time() : strtotime($_REQUEST["month"]);

//获取今日开始时间戳和结束时间戳
$today_start=mktime(0,0,0,date('m',$month),date('d',$month),date('Y',$month));
$today_end=mktime(0,0,0,date('m',$month),date('d',$month)+1,date('Y',$month))-1;

//获取昨日起始时间戳和结束时间戳
$yesterday_start=mktime(0,0,0,date('m',$month),date('d',$month)-1,date('Y',$month));
$yesterday_end=mktime(0,0,0,date('m',$month),date('d',$month),date('Y',$month))-1;

//php获取上周起始时间戳和结束时间戳
$lastweek_start=mktime(0,0,0,date('m',$month),date('d',$month)-date('w',$month)+1-7,date('Y',$month));
$lastweek_end=mktime(23,59,59,date('m',$month),date('d',$month)-date('w',$month)+7-7,date('Y',$month));

//获取本周周起始时间戳和结束时间戳
$thisweek_start=mktime(0,0,0,date('m',$month),date('d',$month)-date('w',$month)+1,date('Y',$month));
$thisweek_end=mktime(23,59,59,date('m',$month),date('d',$month)-date('w',$month)+7,date('Y',$month));


//php获取本月起始时间戳和结束时间戳
$thismonth_start=mktime(0,0,0,date('m',$month),1,date('Y',$month));
$thismonth_end=mktime(23,59,59,date('m',$month),date('t',$month),date('Y',$month));


//php获取本月上旬起始时间戳和结束时间戳
$thismonthf_start=mktime(0,0,0,date('m',$month),1,date('Y',$month));
$thismonthf_end=mktime(23,59,59,date('m',$month),10,date('Y',$month));


//php获取本月中旬起始时间戳和结束时间戳
$thismonths_start=mktime(0,0,0,date('m',$month),11,date('Y',$month));
$thismonths_end=mktime(23,59,59,date('m',$month),20,date('Y',$month));


//php获取本月下旬起始时间戳和结束时间戳
$thismontht_start=mktime(0,0,0,date('m',$month),21,date('Y',$month));
$thismontht_end=mktime(23,59,59,date('m',$month),date('t',$month),date('Y',$month));

 

PS:本月上旬和和中旬均为10天,下旬为本月减去上中旬之后剩下的天数

posted @ 2019-07-22 14:54  远方的异特  阅读(2265)  评论(1编辑  收藏  举报