<?php
$week _begin = mktime (0, 0, 0,date ("M"), Date ("D")-date ("W") +1,date ("Y"));
$week _end = mktime (23,59,59,date ("M"), Date ("D")-date ("W") +7,date ("Y"));
echo $week _begin. ' = = = '. Date (' y-m-d h:i:s ', $week _begin);
echo ' <br/> ';
echo $week _end. ' = = = '. Date (' y-m-d h:i:s ', $week _end);
echo ' <br/> ';
echo Date ("Ymd", Strtotime ("Now"), "\ n";
echo Date ("Ymd", Strtotime ("1 week Monday")), "\ n";
echo Date ("Ymd", Strtotime ("1 week Sunday")), "\ n";
echo Date ("Ymd", Strtotime ("+0 Week Monday")), "\ n";
echo Date ("Ymd", Strtotime ("+0 Week Sunday")), "\ n";
Date (' n ') months
Date ("W") Week of the week
Date ("T") number of days of the month
Echo ' <br> this day:<br> ';
echo Date ("Y-m-d h:i:s", mktime (0, 0, 0,date ("M"), Date ("D"), Date ("Y")), "\ n";
Echo ' <br> last week:<br> ';
echo Date ("Y-m-d h:i:s", mktime (0, 0, 0,date ("M"), Date ("D")-date ("W") +1-7,date ("Y")), "\ n";
echo Date ("Y-m-d h:i:s", Mktime (23,59,59,date ("M"), Date ("D")-date ("W") +7-7,date ("Y")), "\ n";
Echo ' <br> this week:<br> ';
echo Date ("Y-m-d h:i:s", mktime (0, 0, 0,date ("M"), Date ("D")-date ("W") +1,date ("Y")), "\ n";
echo Date ("Y-m-d h:i:s", Mktime (23,59,59,date ("M"), Date ("D")-date ("W") +7,date ("Y")), "\ n";
Echo ' <br> last month:<br> ';
echo Date ("Y-m-d h:i:s", mktime (0, 0, 0,date ("M") -1,1,date ("Y")), "\ n";
echo Date ("Y-m-d h:i:s", Mktime (23,59,59,date ("M"), 0,date ("Y")), "\ n";
Echo ' <br> this month:<br> ';
echo Date ("Y-m-d h:i:s", mktime (0, 0, 0,date ("M"), 1,date ("Y")), "\ n";
echo Date ("Y-m-d h:i:s", Mktime (23,59,59,date ("M"), Date ("T"), Date ("Y")), "\ n";
$getMonthDays = Date ("T", mktime (0, 0, 0,date (' n ') + (date (' n ')-1)%3,1,date ("Y"));//Last month of the quarter
Echo ' <br> this quarter:<br> ';
echo Date (' y-m-d h:i:s ', mktime (0, 0, 0,date (' n ')-(date (' n ')-1)%3,1,date (' Y ')), "\ n";
echo Date (' y-m-d h:i:s ', Mktime (23,59,59,date (' n ') + (date (' n ')-1)%3, $getMonthDays, date (' Y '))), "\ n";
$season = Ceil ((date (' n '))/3);//The month of the first quarter
Echo ' <br> this quarter:<br> ';
echo Date (' y-m-d h:i:s ', mktime (0, 0, 0, $season *3-3+1,1,date (' Y ')), "\ n";
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 ')), "\ n" ;
$season = Ceil ((date (' n '))/3) -1;//quarter of last quarter
Echo ' <br> last quarter:<br> ';
echo Date (' y-m-d h:i:s ', mktime (0, 0, 0, $season *3-3+1,1,date (' Y ')), "\ n";
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 ')), "\ n" ;
PHP Two date subtracted days
<?php
function count_days ($a, $b) {
$a _dt=getdate ($a);
$b _dt=getdate ($b);
$a _new=mktime (12,0,0, $a _dt[' mon '), $a _dt[' mday '], $a _dt[' year ');
$b _new=mktime (12,0,0, $b _dt[' mon '), $b _dt[' Mday '], $b _dt[' year ');
Return round (ABS ($a _new-$b _new)/3600/24);
}
function Count_days ($formdate, $todate) {
Return round (ABS (Strtotime ($formdate)-strtotime ($todate))/3600/24);
}
?>
PHP time to get this week's usage this month