When

PHP Date Recursion library

  • 所有者: tplaner/When
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

When

Date/Calendar recursion library for PHP 7.1+

Build Status
Total Downloads

Author: Tom Planer

Installation

composer require tplaner/When

Current Features

Currently this version does everything version 1 was capable of, it also supports byhour, byminute, and bysecond. Please check the unit tests for information about how to use it.

Here are some basic examples.

// friday the 13th for the next 5 occurrences
$r = new When();
$r->startDate(new DateTime("19980213T090000"))
  ->freq("monthly")
  ->count(5)
  ->byday("fr")
  ->bymonthday(13)
  ->generateOccurrences();

print_r($r->occurrences);
// friday the 13th for the next 5 occurrences rrule
$r = new When();
$r->startDate(new DateTime("19980213T090000"))
  ->rrule("FREQ=MONTHLY;BYDAY=FR;BYMONTHDAY=13")
  ->generateOccurrences();

print_r($r->occurrences);
// friday the 13th for the next 5 occurrences, skipping known friday the 13ths
$r = new When();
$r->startDate(new DateTime("19980213T090000"))
  ->freq("monthly")
  ->count(5)
  ->byday("fr")
  ->bymonthday(13)
  ->exclusions('19990813T090000,20001013T090000')
  ->generateOccurrences();

print_r($r->occurrences);
// friday the 13th forever; see which ones occur in 2018
$r = new When();
$r->startDate(new DateTime("19980213T090000"))
  ->rrule("FREQ=MONTHLY;BYDAY=FR;BYMONTHDAY=13");

$occurrences = $r->getOccurrencesBetween(new DateTime('2018-01-01 09:00:00'),
                                         new DateTime('2019-01-01 09:00:00'));
print_r($occurrences);

License

When is licensed under the MIT License, see LICENSE for specific details.

主要指标

概览
名称与所有者tplaner/When
主编程语言PHP
编程语言PHP (语言数: 1)
平台
许可证MIT License
所有者活动
创建于2010-09-04 00:23:05
推送于2025-02-14 01:18:32
最后一次提交2025-02-13 20:17:11
发布数16
最新版本名称v3.2.1 (发布于 2025-02-13 20:18:12)
第一版名称v0.1 (发布于 )
用户参与
星数520
关注者数25
派生数96
提交数146
已启用问题?
问题数65
打开的问题数2
拉请求数21
打开的拉请求数0
关闭的拉请求数11
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?