如何在星期日和星期一每周重复发生一次wdcalender中有5次出现的事件,如何在wdcalender中写入recurrecerule
参考:http://www.web-delicious.com/jquery-plugins-demo/wdCalendar/sample.php
<?php
function getDateOfWeekDay($day) {
$weekDays = array(
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
);
$dayNumber = array_search($day, $weekDays);
$currentDayNumber = date('w', strtotime('today'));
// if ($dayNumber > $currentDayNumber) {
if ( $currentDayNumber > $dayNumber) {
//return date('Y-m-d', strtotime($day));
echo date('Y-m-d',strtotime($day.' this week'));
} else {
//return date('Y-m-d', strtotime($day) + 604800);
echo date('Y-m-d',strtotime($day.' next week') +1);
}
}
$ron="0,2,6"; // $ron is repeats on every sunday , tuesday, and saturday
$oc=4; // $oc is an occurences how many time it will repeat
$ronS=explode(',', $ron);
foreach($ronS as $ronS) {
$res[]= $ronS;
}
$r=0;
$rr=0;
for($i = 0; $i < $oc; $i++)
{
if($i<count($res))
{
$t=$res[$i];
$r++;
}
else
{
$t=$res[$rr];
$rr++;
}
$week = array('0'=>"Sunday","1"=>"Monday","2"=>"Tuesday","3"=>"Wednesday","4"=>"Thursday","5"=>"Friday","6"=>"Saturday");
$day[] = $week[$t];
}//for
print_r($day);
foreach ($day as $da)
{
echo getDateOfWeekDay($da)."\n";
}
?>
此代码的输出是
Array
(
[0] => Sunday
[1] => Tuesday
[2] => Saturday
[3] => Sunday
)
2014-05-18
2014-05-20
2014-05-24
2014-05-18
所有工作正常,但最后一个日期 2014-05-18 是错误的2014-05-25
任何想法的朋友