1 class Rate 2 { 3 //表 4 protected $autoCheckFields = false; 5 6 //每天送 7 public function rate_1($begintime, $number) 8 { 9 $t = 0;10 for ($i = 1; $i <= $number; $i++) {11 $endtime = $begintime + $t;12 $date[] = $endtime;13 $t = $i * 24 * 60 * 60;14 }15 return $date;16 }17 18 //隔天送19 public function rate_2($begintime, $number)20 {21 $t = 0;22 for ($i = 1; $i <= $number; $i++) {23 $endtime = $begintime + $t;24 $date[] = $endtime;25 $t = $i * 2 * 24 * 60 * 60;26 }27 return $date;28 }29 30 //工作日送31 public function rate_3($begintime, $number)32 {33 $date = array();34 $i = 0;35 while(count($date)<$number)36 {37 $timer = $begintime+60*60*24*$i;38 $num= date("w",$timer);39 if(in_array($num,array(1,2,3,4,5))){40 $date[]=$begintime+60*60*24*$i;41 }42 $i++;43 }44 return $date;45 }46 47 //周末送48 public function rate_4($begintime, $number)49 {50 $date = array();51 $i = 0;52 while(count($date)<$number)53 {54 $timer = $begintime+60*60*24*$i;55 $num= date("w",$timer);56 if(in_array($num,array(0,6))){57 $date[]=$begintime+60*60*24*$i;58 }59 $i++;60 }61 return $date;62 }63 //一三五64 public function rate_5($begintime, $number)65 {66 $date = array();67 $i = 0;68 while(count($date)<$number)69 {70 $timer = $begintime+60*60*24*$i;71 $num= date("w",$timer);72 if(in_array($num,array(1,3,5))){73 $date[]=$begintime+60*60*24*$i;74 }75 $i++;76 }77 return $date;78 }79 //二四六80 public function rate_6($begintime, $number)81 {82 $date = array();83 $i = 0;84 while(count($date)<$number)85 {86 $timer = $begintime+60*60*24*$i;87 $num= date("w",$timer);88 if(in_array($num,array(2,4,6))){89 $date[]=$begintime+60*60*24*$i;90 }91 $i++;92 }93 return $date;94 }95 }
适合周期性操作使用
posted on 2015-12-20 12:36 阅读( ...) 评论( ...)