php日期时间计算,转载
//php获取今天日期date("Y-m-d");
//php获取昨天日期
date("Y-m-d",strtotime("-1 day"))
//php获取明天日期
date("Y-m-d",strtotime("+1 day"))
//php获取一周后日期
date("Y-m-d",strtotime("+1 week"))
//php获取一周零两天四小时两秒后时间
date("Y-m-d G:H:s",strtotime("+1 week 2 days 4 hours 2 seconds"))
//php获取下个星期四日期
date("Y-m-d",strtotime("next Thursday"))
//php获取上个周一日期
date("Y-m-d",strtotime("last Monday"))
//php获取一个月前日期
date("Y-m-d",strtotime("last month"))
//php获取一个月后日期
date("Y-m-d",strtotime("+1 month"))
//php获取十年后日期
date("Y-m-d",strtotime("+10 year"))
//php获取今天起止时间戳
mktime(0,0,0,date('m'),date('d'),date('Y'));
mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
//php获取昨天起止时间戳
mktime(0,0,0,date('m'),date('d')-1,date('Y'));
mktime(0,0,0,date('m'),date('d'),date('Y'))-1;
//php获取上周起止时间戳
mktime(0,0,0,date('m'),date('d')-date('w')+1-7,date('Y'));
mktime(23,59,59,date('m'),date('d')-date('w')+7-7,date('Y'));
//php获取本月起止时间戳
mktime(0,0,0,date('m'),1,date('Y'));
mktime(23,59,59,date('m'),date('t'),date('Y'));
计算起止日期(列出起止日期区间所有日期)
$data=$this->date_range(date('Y-m-d',$time2),date('Y-m-d',$time1));
//起止日期计算
function date_range($first, $last, $step = '+1 day', $format = 'Y-m-d')
{
$dates = array();
$current = strtotime($first);
$last = strtotime($last);
while ($current
页:
[1]