我在我的项目中使用PHP RRule进行重复。在这里,每日和每周重复工作正常。我不知道如何在我的场景中使用每月重复。
每月场景:
每 2 个月的第一个星期日
代码:
$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