I currently allow daily or weekly recurring events in the calendar application (using fullCalendar).
My view has a checkbox that activates two drop-down lists: one for the repetition interval (daily, weekly) and one for the frequency (once, twice, etc.).
$evt_interval_options = array(
'86400' => 'Daily',
'604800' => 'Weekly';
$evt_frequency_options = array(
'1' => '2',
'2' => '3',
<?php echo form_checkbox('evt_repeat', 'FALSE', FALSE, 'class="repeat_checkbox"');
echo form_dropdown('evt_interval', $evt_interval_options');
echo form_dropdown('evt_frequency', $evt_frequency_options'); ?>
This ultimately reaches my model, which starts the loop, checking if the event should be repeated - if so, it will depend on the interval ( $row->interval) and frequency ( $i).
$cal_data[] = array(
'start' => strtotime($row->date_1 . ' ' . $row->time_1) + ($i ? ($row->interval * $i) : 0),
);
This works well to display multiple daily or weekly events based on one entry in the database.
. ,
03/01/2011 00:00:00 --> 04/01/2011 00:00:00 ===> 2674800 seconds
04/01/2011 00:00:00 --> 05/01/2011 00:00:00 ===> 2592000 seconds
and so on for monthly and yearly differences
, ? - strtotime, , . 4th July 4th?
PHP 5.2.14.