1. Obtain week, start and end dates:
echo date("Y-m-d H:i:s", mktime(0,0,0,date("m"),date("d")-date("w")+1,date("Y"))); //2020-03-09 00:00:00 echo date("Y-m-d H:i:s", mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y"))); //2020-03-15 23:59:59
2. Obtain last week the start and end dates:
echo date('Y-m-d H:i:s', mktime(0,0,0,date('m'),date('d')-date('w')+1-7,date('Y'))); //2020-03-02 00:00:00 echo date('Y-m-d H:i:s', mktime(23,59,59,date('m'),date('d')-date('w')+7-7,date('Y'))); //2020-03-08 23:59:59
3. Obtaining this month the start and end dates:
echo date('Y-m-d H:i:s', mktime(0,0,0,date('m'),1,date('Y'))); //2020-03-01 00:00:00 echo date('Y-m-d H:i:s', mktime(23,59,59,date('m'),date('t'),date('Y'))); //2020-03-31 23:59:59
4. Get started last month and ending date:
echo date("Y-m-d H:i:s", mktime(0,0,0,date("m")-1,1,date("Y"))); //2020-02-01 00:00:00 echo date("Y-m-d H:i:s", mktime(23,59,59,date("m") ,0,date("Y"))); //2020-02-29 23:59:59
5. Obtain the quarter start and end dates:
$season = ceil((date('n'))/3); echo date('Y-m-d H:i:s', mktime(0,0,0,$season*3-3+1,1,date('Y'))); //2020-01-01 00:00:00 echo date('Y-m-d H:i:s', mktime(23,59,59,$season*3,date('t',mktime(0,0,0,$season*3,1,date("Y"))),date('Y'))); //2020-03-31 23:59:59
6. Obtain previous quarter start and end dates:
$season = ceil((date('n'))/3)-1;//上季度是第几季度 echo date('Y-m-d H:i:s', mktime(0,0,0,$season*3-3+1,1,date('Y'))); //2019-10-01 00:00:00 echo date('Y-m-d H:i:s', mktime(23,59,59,$season*3,date('t',mktime(0,0,0,$season*3,1,date("Y"))),date('Y')));//2019-12-31 23:59:59
7. acquired this month was the first few months:
the echo the date , ( '' n ''),; // 3
8. Get the day of the week:
echo date("w"); //4
9. Obtain the total number of days this month:
echo date("t"); //31