PHPackages                             datrim/date-range - 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. datrim/date-range

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

datrim/date-range
=================

Date range utility

1.0.5(6y ago)089MITPHPPHP ^7.2.5CI failing

Since Mar 9Pushed 6y ago1 watchersCompare

[ Source](https://github.com/datrim/date-range)[ Packagist](https://packagist.org/packages/datrim/date-range)[ RSS](/packages/datrim-date-range/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (6)Dependencies (2)Versions (7)Used By (0)

DateRange
=========

[](#daterange)

DateRange is a simple package for creating and using a starting and ending date.

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

[](#installation)

### Composer

[](#composer)

From the command line, run:

```
composer require datrim/date-range

```

Usage
-----

[](#usage)

### The Basics

[](#the-basics)

With the package now installed, you may use the two classes like so:

### Create date range for today (00:00 - 23:59)

[](#create-date-range-for-today-0000---2359)

```
use Datrim\DateRange\DateRange;

$today = DateRange::today();
```

### Create date range for last week

[](#create-date-range-for-last-week)

```
use Datrim\DateRange\DateRange;

$today = DateRange::lastWeek();
```

### Create date range for this week

[](#create-date-range-for-this-week)

```
use Datrim\DateRange\DateRange;

$today = DateRange::thisWeek();
```

### Create date range for last month

[](#create-date-range-for-last-month)

```
use Datrim\DateRange\DateRange;

$today = DateRange::lastMonth();
```

### Create date range for this month

[](#create-date-range-for-this-month)

```
use Datrim\DateRange\DateRange;

$today = DateRange::thisMonth();
```

### Create date range for this year

[](#create-date-range-for-this-year)

```
use Datrim\DateRange\DateRange;

$year = DateRange::thisYear();
```

### Create date range for a specified year

[](#create-date-range-for-a-specified-year)

```
use Datrim\DateRange\DateRange;

$year = DateRange::year(2010);
```

### Get the difference between two dates

[](#get-the-difference-between-two-dates)

```
use Datrim\DateRange\DateRange;

$today = DateRange::thisWeek();
$diff  = $today->diff();
```

### Is a date and time included in a date range

[](#is-a-date-and-time-included-in-a-date-range)

```
use Datrim\DateRange\DateRange;

$thisWeek = DateRange::thisWeek();
$today = Carbon::now();
$included = $thisWeek->includes($today);
```

### Also included is a default timezone class.

[](#also-included-is-a-default-timezone-class)

The timezone class is used by the DateRange when creating new Carbon instances. Before using the DateRange class, set the default timezone as follows:

```
use Datrim\DateRange\dt;
use Datrim\DateRange\DateRange;

dt::defaultTimezone('Europe/Berlin');

$today = DateRange::thisWeek();
```

To get the default timezone, call the dt::defaultTimezone method with no parameters:

```
use Datrim\DateRange\dt;

$timezone = dt::defaultTimezone();
```

The dt class has several static methods that wrap Carbon creation methods:

```
dt::now($tz = null)
dt::parse($time = null, $tz = null)
dt::today($tz = null)
dt::tomorrow($tz = null)
dt::yesterday($tz = null)
```

A different timezone string may be passed to all the above methods to override the default timezone.

That's it!

### License

[](#license)

The HttpData package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

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 ~303 days

Recently: every ~377 days

Total

6

Last Release

2250d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.5.9

1.0.4PHP ^7.2.5

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/199539?v=4)[Chris Pritchard](/maintainers/datrim)[@datrim](https://github.com/datrim)

---

Top Contributors

[![datrim](https://avatars.githubusercontent.com/u/199539?v=4)](https://github.com/datrim "datrim (10 commits)")

---

Tags

datecarbondate-range

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/datrim-date-range/health.svg)

```
[![Health](https://phpackages.com/badges/datrim-date-range/health.svg)](https://phpackages.com/packages/datrim-date-range)
```

###  Alternatives

[illuminate/support

The Illuminate Support package.

630113.0M40.8k](/packages/illuminate-support)[kartik-v/yii2-date-range

An advanced Yii 2 date range picker input for based on bootstrap-daterangepicker plugin.

924.6M42](/packages/kartik-v-yii2-date-range)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

54681.3k17](/packages/solspace-craft-freeform)[japanese-date/japanese-date

日本の暦、祝日を取り扱うライブラリ

1610.0k](/packages/japanese-date-japanese-date)[wilianx7/php-recurring

PHP library for generating recurring dates, schedules, and repeated task recurrences.

1050.7k](/packages/wilianx7-php-recurring)

PHPackages © 2026

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