我需要幫助的方式這樣做,而不是代碼(THA是我的工作,我認爲;))PHP:添加事件到一個星期的工作日
我需要分發的訪問的供應商必須做在工作日的一個月內。 本月我有100人蔘觀,有不同的定期參數。
25人每月訪問一次。 25人,每月兩次參觀 25人每週一次參觀 25人每天
我需要分發每月的第一天,所有這些訪問參觀,throught該月的所有工作日和我真的不知道我該怎麼辦。
我得到的一些數據我想我需要下一個代碼:
$days_this_month = date("d",mktime(0,0,0,$month+1,0,$year));
function weeks_this_month($year, $month, $start = 0) {
$unix = strtotime ("$year-$month-01");
$numDays = date ('t', $unix);
if ($start === 0) {
$dayOne = date ('w', $unix); // Based on 0-6
} else {
$dayOne = date ('N', $unix); //based on 1-7
$dayOne --; //convert for 0 based weeks
}
//if day one is not the start of the week then advance to start
$numWeeks = floor (($numDays - (6 - $dayOne))/7);
return $numWeeks;
}
$weeks_this_month = weeks_this_month($year, $month);
我也得到了天,每週有:
$weekArray = array();
// set current date1
$date = date("m/d/Y"); //'05/09/2011';
$date = "05/11/2011"; //'05/09/2011';
// parse about any English textual datetime description into a Unix timestamp
$ts = strtotime($date);
// calculate the number of days since Monday
$dow = date('w', $ts);
$offset = $dow - 1;
if ($offset < 0) $offset = 6;
// calculate timestamp for the Monday
$ts = $ts - $offset*86400;
// loop from Monday till Sunday
for ($i=0; $i<7; $i++, $ts+=86400){
$temp_date = date("Y-m-d", $ts); // here I set it to the same format as my database
array_push($weekArray, $temp_date);
}
print_r ($weekArray);
隨着當前結果:
[0] => 2011-05-09
[1] => 2011-05-10
[2] => 2011-05-11
[3] => 2011-05-12
[4] => 2011-05-13
[5] => 2011-05-14
[6] => 2011-05-15
而我的最後一張支票是一個函數,用於瞭解結果日期是否爲工作日,而不是週六或週日。
問題是我真的迷路了。
我不知道如何混合所有這些信息來分發供應商訪問。
任何人都可以給我一個想法嗎?
真的thnx。
你可以進一步解釋一下,你究竟在做什麼? – Yoshi 2011-05-02 11:52:25
嗨,你好,我試圖解釋更好的編輯帖子。日Thnx! – SauronZ 2011-05-02 12:01:23
「拜訪」你的意思是供應商必須去某個地方?你想計算什麼供應商必須訪問誰? – Yoshi 2011-05-02 13:08:14