Frage

I currently allow for daily or weekly repeating events on my calendar app (using fullCalendar).

My view has a checkbox that activates two dropdowns: one for the repeat interval (daily, weekly) and one for the frequency (once, twice, etc).

$evt_interval_options = array( //this will be $row->interval in the model
    '86400' => 'Daily',   
    '604800' => 'Weekly'; 

$evt_frequency_options = array(  //this will be //$i in the model
    '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 eventually reaches my model, which runs a loop checking if the event should repeat -- if so, it will factor in the interval ($row->interval) and the frequency ($i).

$cal_data[] = array(
    'start' => strtotime($row->date_1 . ' ' . $row->time_1) + ($i ? ($row->interval * $i) : 0),
);

This works nicely to show multiple daily or weekly events based on a single record entry in the database.

The problem is with monthly and yearly. Since these will have variable number of seconds because

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

So how do I resolve this issue? Is there any function or strtotime command that can help indicate precisely that a monthly should repeat on the e.g. 4th or an yearly should repeat on July 4th?

I am using PHP 5.2.14.

Keine korrekte Lösung

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top