PHPackages                             gtmassey/period - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. gtmassey/period

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

gtmassey/period
===============

Create date ranges and periods of time with ease.

v1.3.1(11mo ago)070.8k↓37.1%32MITPHPPHP ^8.1|^8.2|^8.3CI passing

Since Dec 6Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/gtmassey/period)[ Packagist](https://packagist.org/packages/gtmassey/period)[ Docs](https://github.com/gtmassey/period)[ RSS](/packages/gtmassey-period/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (13)Versions (8)Used By (2)

Period
======

[](#period)

[![Latest Version on Packagist](https://camo.githubusercontent.com/638ade58d78e53974959f4890ffc81c8f80695eda046ddbd8e50e012efbb2f5f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f67746d61737365792f706572696f642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gtmassey/period)[![Total Downloads](https://camo.githubusercontent.com/5071f550d48e0abdafc31fef768826d3883941f82a0cd7a68d13c8d951d7f29f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f67746d61737365792f706572696f642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gtmassey/period)[![Tests](https://github.com/gtmassey/period/actions/workflows/run-tests.yml/badge.svg)](https://github.com/gtmassey/period/actions/workflows/run-tests.yml)

Create date ranges and periods of time with ease.

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

[](#installation)

You can install the package via composer:

```
composer require gtmassey/period
```

Usage
-----

[](#usage)

All instances of Period take in Carbon instances for the `startDate` and `endDate`.

You can define a period by passing a start and end date to the static `create` method:

```
$customPeriod = Period::create(Carbon::now()->subDays(3), Carbon::now());
```

You can also use one of the many methods provided for you to generate pre-defined periods of time:

```
//days
Period::today();
Period::yesterday();
Period::lastDays(int $days); //$days = 2
Period::lastDaysExcludingToday(int $days); //$days = 2

//weeks
Period::thisWeek();
Period::thisWeekExcludingToday();
Period::lastWeek();
Period::lastWeeks(int $weeks);

//months
Period::thisMonth();
Period::thisMonthExcludingToday();
Period::lastMonth();
Period::lastMonths(int $months);

//quarters (3 months)
Period::thisQuarter();
Period::thisQuarterExcludingToday();
Period::lastQuarter();
Period::lastQuarters(int $quarters);

//years
Period::thisYear();
Period::thisYearExcludingToday();
Period::lastYear();
Period::lastYears(int $years);
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Garrett Massey](https://github.com/gtmassey)
- [Plytas](https://github.com/plytas)
- [All Contributors](../../contributors)

This package was extracted from [gtmassey/laravel-analytics](https://github.com/gtmassey/laravel-analytics). A special thanks goes to [Plytas](https://github.com/plytas) for their help in creating the original package this code is extracted from.

Thank you to the team at [Spatie](https://github.com/spatie) for their awesome packages and inspiration. Their laravel-analytics package was the inspiration for this project and the analytics project.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance50

Moderate activity, may be stable

Popularity32

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 92% 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 ~226 days

Total

5

Last Release

355d ago

PHP version history (3 changes)v1.0.0PHP ^8.1

v1.3.0PHP ^8.2|^8.3

v1.3.1PHP ^8.1|^8.2|^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/f198e204b73532fa68ddd5c60c226cbc25eb9113cfac0bea19337434e944e2d4?d=identicon)[gtmassey](/maintainers/gtmassey)

---

Top Contributors

[![gtmassey](https://avatars.githubusercontent.com/u/109831143?v=4)](https://github.com/gtmassey "gtmassey (23 commits)")[![oriceon](https://avatars.githubusercontent.com/u/358823?v=4)](https://github.com/oriceon "oriceon (1 commits)")[![Plytas](https://avatars.githubusercontent.com/u/17316322?v=4)](https://github.com/Plytas "Plytas (1 commits)")

---

Tags

laravelperiodgtmassey

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/gtmassey-period/health.svg)

```
[![Health](https://phpackages.com/badges/gtmassey-period/health.svg)](https://phpackages.com/packages/gtmassey-period)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.8k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

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