nickjbedford/calendar-timer

Provides classes to calculate past and future schedule dates based on a reference date.

0.1.0 2021-02-16 22:18 UTC

This package is auto-updated.

Last update: 2024-04-17 05:11:01 UTC


README

Provides day, month and year-based calendar schedule calculation. For each type of timer, a reference date along with an interval is used to calculate past and future dates, from any date including now.

For example, to calculate a fortnightly schedule of dates from Wednesday 6th January 2021, you can use the following code:

use \YetAnother\DayTimer;

$scheduler = new DayTimer('2021-01-04', 14);

// get next 3 dates from 1st February 2021
$dates = $scheduler->getDates(3, '2021-02-01'); 

// $dates = [
//   '2021-02-03'
//   '2021-02-17'
//   '2021-03-03'
// ]

Alternatively you can use the provided helper methods to create calendar timer. These create instances of the DayTimer, MonthTimer or YearTimer subclasses depending on the helper.

use \YetAnother\CalendarTimer;

$date = '2020-01-04';

$weekly = CalendarTimer::weekly($date);
$fortnightly = CalendarTimer::fortnightly($date);
$monthly = CalendarTimer::monthly($date);
$biannual = CalendarTimer::sixMonthly($date);
$yearly = CalendarTimer::yearly($date);