The following code can be abbreviated AH?
The following code is not a simple way to achieve ah, I think this is too complicated to write, if you write one months of data, it is not necessary to write 30 case
I'm a novice, I beg the hero's help
Date_default_timezone_set (' PRC ');
$c 1=0;
$c 2=0;
$c 3=0;
$c 4=0;
$c 5=0;
$c 6=0;
$c 7=0;
$w = Date ("W", Time ());
Switch ($w) {
Case 1:
Break
Case 2:
$t 1=strtotime (Date ("y-m-d"). " 23:59:59 ");//Tuesday
$t 2=strtotime (Date ("Y-m-d", Strtotime ("1 day")). " 23:59:59 ");//Mon
if ($t 2<1387420136&&1387420136<= $t 1) {
$c 1 + = 1;
}elseif (1387420136<= $t 2) {
$c 2 + = 1;
}
echo $c 1;
Break
Case 3:
$t 1=strtotime (Date ("y-m-d"). " 23:59:59 ");//Wednesday
$t 2=strtotime (Date ("Y-m-d", Strtotime ("1 day")). " 23:59:59 ");//Tuesday
$t 3=strtotime (Date ("Y-m-d", Strtotime ("2 Day")). " 23:59:59 ");//Mon
if ($t 2<1387420136&&1387420136<= $t 1) {
$c 1 + = 1;
}elseif ($t 3<1387420136&&1387420136<= $t 2) {
$c 2 + = 1;
}elseif (1387420136<= $t 3) {
$c 3 + = 1;
}
echo $c 1;
Break
Case 4:
$t 1=strtotime (Date ("y-m-d"). " 23:59:59 ");//Thursday
$t 2=strtotime (Date ("Y-m-d", Strtotime ("1 day")). " 23:59:59 ");//Wednesday
$t 3=strtotime (Date ("Y-m-d", Strtotime ("2 Day")). " 23:59:59 ");//Tuesday
$t 4=strtotime (Date ("Y-m-d", Strtotime ("3 Day")). " 23:59:59 ");//Mon
if ($t 2<1387420136&&1387420136<= $t 1) {
$c 1 + = 1;
}elseif ($t 3<1387420136&&1387420136<= $t 2) {
$c 2 + = 1;
}elseif ($t 4<1387420136&&1387420136<= $t 3) {
$c 3 + = 1;
}elseif (1387420136<= $t 4) {
$c 4 + = 1;
}
echo $c 1;
Break
Case 5:
$t 1=strtotime (Date ("y-m-d"). " 23:59:59 ");//Friday
$t 2=strtotime (Date ("Y-m-d", Strtotime ("1 day")). " 23:59:59 ");//Thursday
$t 3=strtotime (Date ("Y-m-d", Strtotime ("2 Day")). " 23:59:59 ");//Wednesday
$t 4=strtotime (Date ("Y-m-d", Strtotime ("3 Day")). " 23:59:59 ");//Tuesday
$t 5=strtotime (Date ("Y-m-d", Strtotime ("4 Day")). " 23:59:59 ");//Mon
if ($t 2<1387420136&&1387420136<= $t 1) {
$c 1 + = 1;
}elseif ($t 3<1387420136&&1387420136<= $t 2) {
$c 2 + = 1;
}elseif ($t 4<1387420136&&1387420136<= $t 3) {
$c 3 + = 1;
}elseif ($t 5<1387420136&&1387420136<= $t 4) {
$c 4 + = 1;
}elseif (1387420136<= $t 5) {
$c 5 + = 1;
}
echo $c 1;
Break
Case 6:
$t 1=strtotime (Date ("y-m-d"). " 23:59:59 ");//Saturday
$t 2=strtotime (Date ("Y-m-d", Strtotime ("1 day")). " 23:59:59 ");//Friday
$t 3=strtotime (Date ("Y-m-d", Strtotime ("2 Day")). " 23:59:59 ");//Thursday
$t 4=strtotime (Date ("Y-m-d", Strtotime ("3 Day")). " 23:59:59 ");//Wednesday
$t 5=strtotime (Date ("Y-m-d", Strtotime ("4 Day")). " 23:59:59 ");//Tuesday
$t 6=strtotime (Date ("Y-m-d", Strtotime ("5 Day")). " 23:59:59 ");//Mon
if ($t 2<1387420136&&1387420136<= $t 1) {
$c 1 + = 1;
}elseif ($t 3<1387420136&&1387420136<= $t 2) {
$c 2 + = 1;
}elseif ($t 4<1387420136&&1387420136<= $t 3) {
$c 3 + = 1;
}elseif ($t 5<1387420136&&1387420136<= $t 4) {
$c 4 + = 1;
}elseif ($t 6<1387420136&&1387420136<= $t 5) {
$c 5 + = 1;
}elseif (1387420136<= $t 6) {
$c 6 + = 1;
}
echo $c 1;
Break
Case 7:
$t 1=strtotime (Date ("y-m-d"). " 23:59:59 ");//Sunday
$t 2=strtotime (Date ("Y-m-d", Strtotime ("1 day")). " 23:59:59 ");//Saturday
$t 3=strtotime (Date ("Y-m-d", Strtotime ("2 Day")). " 23:59:59 ");//Friday
$t 4=strtotime (Date ("Y-m-d", Strtotime ("3 Day")). " 23:59:59 ");//Thursday
$t 5=strtotime (Date ("Y-m-d", Strtotime ("4 Day")). " 23:59:59 ");//Wednesday
$t 6=strtotime (Date ("Y-m-d", Strtotime ("5 Day")). " 23:59:59 ");//Tuesday
$t 7=strtotime (Date ("Y-m-d", Strtotime ("6 Day")). " 23:59:59 ");//Mon
if ($t 2<1387420136&&1387420136<= $t 1) {
$c 1 + = 1;
}elseif ($t 3<1387420136&&1387420136<= $t 2) {
$c 2 + = 1;
}elseif ($t 4<1387420136&&1387420136<= $t 3) {
$c 3 + = 1;
}elseif ($t 5<1387420136&&1387420136<= $t 4) {
$c 4 + = 1;
}elseif ($t 6<1387420136&&1387420136<= $t 5) {
$c 5 + = 1;
}elseif ($t 7<1387420136&&1387420136<= $t 6) {
$c 6 + = 1;
}elseif (1387420136<= $t 7) {
$c 7 + = 1;
}
echo $c 1;
Break
Default:;
}
?>
Share to: more