php-rrule

Lightweight and fast recurring dates library for PHP (RFC 5545)

Github星跟踪图

RRULE for PHP

Lightweight and fast implementation of recurrence rules for PHP (RRULE from RFC 5545), to easily calculate recurring/repeating dates and events (such as in a calendar).
This library started as a port of python-dateutil.

Build Status
Latest Stable Version
Total Downloads

Basic example

use RRule\RRule;

$rrule = new RRule([
	'FREQ' => 'MONTHLY',
	'INTERVAL' => 1,
	'DTSTART' => '2015-06-01',
	'COUNT' => 6
]);

foreach ($rrule as $occurrence) {
	echo $occurrence->format('D d M Y'),", ";
}
// Mon 01 Jun 2015, Wed 01 Jul 2015, Sat 01 Aug 2015, Tue 01 Sep 2015, Thu 01 Oct 2015, Sun 01 Nov 2015

echo $rrule->humanReadable(),"\n";
// monthly on the 1st of the month, starting from 01/06/2015, 6 times

Complete documentation and more examples are available in the wiki.

Requirements

  • PHP >= 5.6
  • intl extension is recommended for humanReadable() but not strictly required

Installation

The recommended way is to install the lib through Composer.

Simply run composer require rlanvin/php-rrule for it to be automatically installed and included in your composer.json.

Now you can use the autoloader, and you will have access to the library:

require 'vendor/autoload.php';

Documentation

Complete documentation is available in the wiki.

You will also find useful information in the RFC 5545 section 3.3.10.

Contribution

Feel free to contribute! Just create a new issue or a new pull request.

The coding style is (mostly) PSR-2, but with tabs.

Note

I started this library because I wasn't happy with the existing implementations
in PHP, so I thought it would be a good learning project to port the
python-dateutil rrule implementation into PHP.

The Python lib was a bit difficult to understand because the algorithms
are not commented and the variables are very opaque (I'm looking at
you lno1wkst). I tried to comment and explain as much of the algorithm as possible
in this PHP port, so feel free to check the code if you're interested.

The lib differs from the python version in various aspects, notably in the
respect of the RFC. This version is a bit strictier and will not accept many
non-compliant combinations of rule parts, that the python version otherwise accepts.
There are also some additional features in this version.

License

This library is released under the MIT License.

主要指标

概览
名称与所有者rlanvin/php-rrule
主编程语言PHP
编程语言PHP (语言数: 1)
平台
许可证Other
所有者活动
创建于2015-06-24 16:25:34
推送于2025-02-21 08:23:08
最后一次提交2025-02-21 09:20:23
发布数29
最新版本名称v2.5.2 (发布于 )
第一版名称v1.0.0 (发布于 )
用户参与
星数638
关注者数20
派生数86
提交数211
已启用问题?
问题数98
打开的问题数10
拉请求数47
打开的拉请求数6
关闭的拉请求数10
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?