php獲取今日、昨日、最近7天、最近30天等時間的方法
date('Y-m-d',timestamp);
//輸出年-月-日date('Y-m-d H:i:s',timestamp);
//輸出年-月-日 時:分:秒
//php獲取今天日期date("Y-m-d",strtotime("today"));
//strtotime(‘today’)輸出今天的開始時間戳
或date("Y-m-d",time());
//time()輸出當前秒時間戳
//php獲取昨天日期date("Y-m-d",strtotime("-1 day"));
或date("Y-m-d",strtotime("yesterday"));
//php獲取明天日期date("Y-m-d",strtotime("+1 day"));
date("Y-m-d",strtotime("tomorrow "));
//php獲取7天后日期date("Y-m-d",strtotime("+7 day"));
//php獲取30天后日期date("Y-m-d",strtotime("+30 day"));
//php獲取一週後日期date("Y-m-d",strtotime("+1 week"));
//php獲取一個月後日期date("Y-m-d",strtotime("+1 month"));
//php獲取一個月前日期date("Y-m-d",strtotime("last month"));
或date("Y-m-d",strtotime("-1 month"));
//php獲取一年後日期date("Y-m-d",strtotime("+1 year"));
//php獲取一週零兩天四小時五分鐘兩秒後時間date("Y-m-d H:i:s",strtotime("+1 week 2 days 4 hours 5 minute 2 seconds"));
//php獲取下個星期四日期date("Y-m-d",strtotime("next Thursday"));
//php獲取上個週一日期date("Y-m-d",strtotime("last Monday"));
//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'));