When

PHP Date Recursion library

  • Owner: tplaner/When
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

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.

Main metrics

Overview
Name With Ownertplaner/When
Primary LanguagePHP
Program languagePHP (Language Count: 1)
Platform
License:MIT License
所有者活动
Created At2010-09-04 00:23:05
Pushed At2025-02-14 01:18:32
Last Commit At2025-02-13 20:17:11
Release Count16
Last Release Namev3.2.1 (Posted on 2025-02-13 20:18:12)
First Release Namev0.1 (Posted on )
用户参与
Stargazers Count515
Watchers Count25
Fork Count97
Commits Count146
Has Issues Enabled
Issues Count65
Issue Open Count2
Pull Requests Count21
Pull Requests Open Count0
Pull Requests Close Count11
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private