我需要帮助的方式这样做,而不是代码(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