Php 重复事件
我正在尝试允许用户在类似于谷歌日历的日历应用程序中安排活动。我需要实现每3周重复一次的事件,在2次事件发生后结束 我目前的代码如下:Php 重复事件,php,calendar,Php,Calendar,我正在尝试允许用户在类似于谷歌日历的日历应用程序中安排活动。我需要实现每3周重复一次的事件,在2次事件发生后结束 我目前的代码如下: $week = array('0'=>"Sunday","1"=>"Monday","2"=>"Tuesday","3"=>"Wednesday","4"=>"Thursday","5"=>"Friday","6"=>"Saturday"); $day = $week[$val
$week = array('0'=>"Sunday","1"=>"Monday","2"=>"Tuesday","3"=>"Wednesday","4"=>"Thursday","5"=>"Friday","6"=>"Saturday");
$day = $week[$val];
$days = array(
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
'Sunday',
);
$today = new DateTime($day);
//$today = new DateTime('Friday'); //can set specific day if needed
// print "Today is " . $today->format('l') . "\n";
foreach($days as $day) {
$diff = new DateTime($day);
$diff = $diff->format('N') - $today->format('N');
if($diff > 0) {
//print "$day is $diff days in the future\n";
//print "\n$diff days future\n";
$st=date('Y-m-d H:i:s',strtotime('+'.($diff).' day',strtotime($s)));
$et=date('Y-m-d H:i:s',strtotime('+'.$date_diff.'day',strtotime($s)));
}
elseif($diff < 0) {
$diff = abs($diff);
// print "$day is $diff days in the past\n";
// print "$diff days fast\n";
$st=date('Y-m-d H:i:s',strtotime('+'.($diff).' day',strtotime($s)));
$et=date('Y-m-d H:i:s',strtotime('+'.$date_diff.'day',strtotime($s)));
}
else {
$st=date('Y-m-d H:i:s',strtotime('+'.$recordsave.' day',strtotime($s)));
$et=date('Y-m-d H:i:s',strtotime('+'.$date_diff.'day',strtotime($s)));
}
}
有什么好主意吗?激活PHP代码的唯一方法是用户正在访问它。我建议对这件事采取行动
通过在CRON作业中每3周调用一次PHP页面,连续两周,可以设置CRON计划来运行特定的代码行 嘿,朋友,我像谷歌日历应用程序一样开发,我需要在用户添加事件后显示您的问题有点模糊,现在编辑以实现您的前提。