//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获取本周周起始时间戳和结束时间戳
$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'));
//今天开始时间
$date=mktime(0,0,0,date('m'),date('d'),date('Y'));
//转换成2018-05-21格式
$date=date("Y-m-d", $date);
//转换成20180521
$date=str_replace('-', '', $date);
//获得年2018
$currentYear=substr($date, 0, 4);
//获得月05
$currentMonth=substr($date, 4, 2);
//创造一个当月月初的字符串,此处以2018-05-01为例
$startDate="{$currentYear}-{$currentMonth}-01";
//创造一个当月月底的字符串,此处以2018-05-31为例
$endDate=date('Y-m-d', strtotime("$startDate +1 month -1 days"));
//获得当月天数,结果为31
$dayNum= date('t', strtotime("{$currentYear}-{$currentMonth}"));
//获取某月有多少天
cal_days_in_month(CAL_GREGORIAN,$month,$year);
//循环出开始到结束时间
while (strtotime($startDate) <= strtotime($endDate)){
//下一天
$startDate = date ("Y-m-d", strtotime("+1 day", strtotime($startDate)));
}
时间戳换算
最新推荐文章于 2023-11-09 14:23:55 发布