PHP 每月重复

标签 php fullcalendar recurrence rrule

我正在使用 PHP RRule在我的项目中重复出现。 在这里,每日和每周重复工作正常。 我不知道如何在我的场景中使用每月重复。

每月情景:

First Sunday of every 2 Months

enter image description here

代码:

$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 

最佳答案

您不需要BYMONTHDAY,您需要带有数字前缀的BYDAY

在您的情况下:'BYDAY' => '1SU' 表示“第一个星期日”。 2SU 第二个星期日,-1SU 最后一个星期日等

更多信息:

关于PHP 每月重复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40718343/

相关文章:

icalendar - iCalendar 中的 RECURRENCE-ID (RFC 5545)

algorithm - 找出给定的负递归关系的时间复杂度

php - PHP解析/语法错误;以及如何解决它们

php - 使用上一个/下一个按钮将整数插入我的表格的最佳方法

fullcalendar - 如何在 angular 7 的 fullcalendar 中使用语言环境

jquery - Trebuchet MS 字体的奇怪错误

php - Magento 值 '29,990000' 必须是数字

javascript - 使用 angularjs 和 php 登录

javascript - FullCalendar "cannot read property ' getDay' 未定义”

sql-server-2008 - "neater"节假日计算方式