if($type= = 1) {//Day $time[' start '] =Mktime(0, 0, 0,Date(' m '),Date(' d '),Date(' Y ')); $time[' End '] =Mktime(0, 0, 0,Date(' m '),Date(' d ') + 1,Date(' Y ')) -1; }Else if($type==2){ //Week $time[' start '] =Mktime(0, 0, 0,Date("M"),Date("D")-Date("W") +1,Date("Y")); $time[' End '] =Mktime(23,59,59,Date("M"),Date("D")-Date("W") +7,Date("Y")); } Else if($type==3){ //Month $time[' start '] =Mktime(0, 0, 0,Date("M"), 1,Date("Y")); $time[' End '] =Mktime(23,59,59,Date("M"),Date("T"),Date("Y")); }Else if($type= = 4){ //Quarterly $season=Ceil((Date(' n ')) /3);//The first quarter of the month $time[' start '] =Mktime(0, 0, 0,$season*3-3+1,1,Date(' Y ')); $time[' End '] =Mktime(23,59,59,$season,Date(' t ',Mktime(0, 0, 0,$season*3,1,Date("Y"))),Date(' Y ')); }Else if($type= = 5 ){ //years $time[' start '] =Mktime(0, 0, 0,1,1,Date(' Y ')); $time[' End '] =Mktime(23,59,59,12,31,Date("Y")); }
PHP calculates the day, week, month, quarter, year, time stamp range based on the time of day