2016-11-21 7 views
2

Ich verwende PHP RRule für Wiederholung in meinem Projekt. Hier tägliche und wöchentliche Wiederholung funktionieren gut. Ich weiß nicht, wie man monatliche Wiederholung in meinem Szenario verwendet.PHP Monatliche Wiederholung

Monats Szenario:

Erster Sonntag alle 2 Monate

enter image description here

Code:

$dow=array("SU"); 
$rrule = new RRule([ 
    'FREQ' => 'MONTHLY', 
    'BYMONTHDAY' => 2, 
    'INTERVAL' => 2, 
    'BYDAY' => $dow,  
    'DTSTART' => '2016-12-01', 
    'UNTIL' => '2017-12-31' 
]); 

foreach ($rrule as $occurrence) { 
    echo "</br>"; 
    echo $occurrence->format('D Y-m-d'); 
} 

echo $rrule->humanReadable(),"\n"; 

//OUTPUT 
Sun 2017-04-02 
every 2 months on Sunday on the 2nd of the month, starting from 12/1/16, until 12/31/17 

Antwort