0
我試圖讓用戶在類似於Google日曆的日曆應用中安排事件。我要做到這一點每3個星期重複的活動,經過2出現(一個或多個)結束重複發生的事件php
我當前的代碼如下:
$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)));
}
}
任何想法的朋友?
嘿朋友即時通訊開發像谷歌日曆應用程序,我需要在用戶添加事件後顯示 –
您的問題有點含糊,編輯現在實現您的前提。 –