PHPackages                             ecommit/frequency-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. ecommit/frequency-generator

ActiveLibrary

ecommit/frequency-generator
===========================

Get the next date by frequency.

v2.1.1(1mo ago)06.2k↓100%2MITPHPPHP ^7.4|^8.0CI passing

Since Aug 21Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/e-commit/frequency-generator)[ Packagist](https://packagist.org/packages/ecommit/frequency-generator)[ RSS](/packages/ecommit-frequency-generator/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (7)Used By (0)

Frequency generator
===================

[](#frequency-generator)

Get the next date (DateTime object) by frequency.

[![Tests](https://github.com/e-commit/frequency-generator/workflows/Tests/badge.svg)](https://github.com/e-commit/frequency-generator/workflows/Tests/badge.svg)

Installation
------------

[](#installation)

To install frequency-generator with Composer just run :

```
$ composer require ecommit/frequency-generator
```

Usage
-----

[](#usage)

### Create generator

[](#create-generator)

```
use Ecommit\FrequencyGenerator\FrequencyGenerator;

$generator = new FrequencyGenerator();
```

### Frequency "every day"

[](#frequency-every-day)

```
//Every day at 08:00:00 and 10:00:00
$dateTimeObject = $generator->nextInEveryDay([new \DateTime('10:00:00'), new \DateTime('08:00:00')]);
```

Arguments :

- **array $times** Times (Array of DateTime or DateTimeImmutable objects). Default: only *00:00:00*

### Frequency "every week"

[](#frequency-every-week)

```
//Every monday (at 08:00:00 and 10:00:00) and tuesday (at 08:00:00 and 10:00:00)
$dateTimeObject = $generator->nextInEveryWeek([1, 2], [new \DateTime('10:00:00'), new \DateTime('08:00:00')]);
```

Arguments :

- **array $days** Array of days in week (integers). (1=Monday =&gt; 7=Sunday). Default: Only *1* (monday)
- **array $times** Times (Array of DateTime or DateTimeImmutable objects). Default: only *00:00:00*

### Frequency "every month"

[](#frequency-every-month)

```
//Every 1st (at 08:00:00 and 10:00:00) and 2nd (at 08:00:00 and 10:00:00)
$dateTimeObject = $generator->nextInEveryMonth([1, 2], [new \DateTime('10:00:00'), new \DateTime('08:00:00')]);
```

Arguments :

- **array $days** Array of days in month (integers). (1=&gt;31). Default: Only *1* (1st)
- **array $times** Times (Array of DateTime or DateTimeImmutable objects). Default: only *00:00:00*

### Frequency "every quart"

[](#frequency-every-quart)

```
//Every 1st and 15th February, May, August and November (at 08:00:00 and 10:00:00)
$dateTimeObject = $generator->nextInEveryQuart([2], [1, 15], [new \DateTime('10:00:00'), new \DateTime('08:00:00')]);
```

Arguments :

- **array $monthOffsets** Array of month offsets in quart (integers). (1 = January, April, July, October. 2 = February, May, August, November. 3 = March, June, September, December). Default: Only *1* (January, April, July, October)
- **array $daysInMonth** Array of days in month (integers). (1=&gt;31). Default: Only *1* (1st)
- **array $times** Times (Array of DateTime or DateTimeImmutable objects). Default: only *00:00:00*

### Frequency "every half year"

[](#frequency-every-half-year)

```
//Every 1st and 15th February and August (at 08:00:00 and 10:00:00)
$dateTimeObject = $generator->nextInEveryHalfYear([2], [1, 15], [new \DateTime('10:00:00'), new \DateTime('08:00:00')]);
```

- **array $monthOffsets** Array of month offsets in half year (integers). 1 = January, July. 2 = February, August. 3 = March, September. 4 = April, October. 5 = May , November. 6 = June, December). Default: Only *1* (January, July)
- **array $daysInMonth** Array of days in month (integers). (1=&gt;31). Default: Only *1* (1st)
- **array $times** Times (Array of DateTime or DateTimeImmutable objects). Default: only *00:00:00*

### Frequency "every year"

[](#frequency-every-year)

```
//Every 1st and 15th January (at 08:00:00 and 10:00:00)
$dateTimeObject = $generator->nextInEveryYear([1], [1, 15], [new \DateTime('10:00:00'), new \DateTime('08:00:00')]);
```

- **array $monthOffsets** Array of month offsets in year (integers). (1 = January =&gt; 12 =&gt; December). Default: Only *1* (January)
- **array $daysInMonth** Array of days in month (integers). (1=&gt;31). Default: Only *1* (1st)
- **array $times** Times (Array of DateTime or DateTimeImmutable objects). Default: only *00:00:00*

Generate DateTimeImmutable objects
----------------------------------

[](#generate-datetimeimmutable-objects)

The generator generates by default DateTime objects.

The generator can generate DateTimeImmutable objets with `generateDateTimeImmutable` method:

```
use Ecommit\FrequencyGenerator\FrequencyGenerator;

$generator = new FrequencyGenerator();

$date = $generator->nextInEveryDay([new \DateTime('10:00:00'), new \DateTime('08:00:00')]);
echo get_class($date); //This example will output "DateTime"

$generator->generateDateTimeImmutable(true);
$date = $generator->nextInEveryDay([new \DateTime('10:00:00'), new \DateTime('08:00:00')]);
echo get_class($date); //This example will output "DateTimeImmutable"

$generator->generateDateTimeImmutable(false);
$date = $generator->nextInEveryDay([new \DateTime('10:00:00'), new \DateTime('08:00:00')]);
echo get_class($date); //This example will output "DateTime"
```

License
-------

[](#license)

This librairy is under the MIT license. See the complete license in *LICENSE* file.

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance93

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~693 days

Recently: every ~471 days

Total

6

Last Release

34d ago

Major Versions

v1.0.0 → v2.0.02020-12-20

PHP version history (2 changes)v2.0.0PHP ^7.2|^8.0

v2.1.0PHP ^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/73191162d97fffaa1a23d23326a7a77fbaa94ce41e49cf4ee6cbf0b9c9800c80?d=identicon)[e-commit](/maintainers/e-commit)

---

Top Contributors

[![hlecorche](https://avatars.githubusercontent.com/u/188749?v=4)](https://github.com/hlecorche "hlecorche (55 commits)")

---

Tags

frequencyfrequency-generatorphpfrequencyperiodMonthYeardayweekmonthlyweeklyyearlyquarthalf yeardaylyquartly

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ecommit-frequency-generator/health.svg)

```
[![Health](https://phpackages.com/badges/ecommit-frequency-generator/health.svg)](https://phpackages.com/packages/ecommit-frequency-generator)
```

###  Alternatives

[brick/date-time

Date and time library

3643.1M42](/packages/brick-date-time)[spatie/period

Complex period comparisons

1.7k3.9M8](/packages/spatie-period)[league/period

Time range API for PHP

7535.3M17](/packages/league-period)[kirouane/interval

Library to handel intervals

2874.2k](/packages/kirouane-interval)[orisai/scheduler

Cron job scheduler - with locks, parallelism and more

4034.8k4](/packages/orisai-scheduler)[orangesoft/throttler

Load balancer between nodes.

1731.3k](/packages/orangesoft-throttler)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
