PHPackages                             iescarro/php-util - 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. iescarro/php-util

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

iescarro/php-util
=================

v0.1.7(8mo ago)01462MITPHP

Since Jul 17Pushed 8mo agoCompare

[ Source](https://github.com/iescarro/php-util)[ Packagist](https://packagist.org/packages/iescarro/php-util)[ RSS](/packages/iescarro-php-util/feed)WikiDiscussions main Synced today

READMEChangelog (8)Dependencies (1)Versions (9)Used By (2)

📆 Util\\Date
============

[](#-utildate)

A simple and expressive utility class for handling date and time operations in PHP, inspired by the readability of frameworks like Laravel and Rails.

---

🚀 Features
----------

[](#-features)

- Chainable and readable date calculations
- Expressive API (e.g., `Date::now()->days(3)->ago()`)
- Easily extendable
- Built-in constants for consistent formatting
- Supports relative time manipulation (seconds, minutes, hours, days, months, years)

---

📦 Installation
--------------

[](#-installation)

You can install the package via Composer:

```
composer require iescarro/php-util
```

Make sure your project supports PSR-4 autoloading.

If you're loading it manually or without a full Composer project, ensure your autoloader includes the Util\\ namespace:

```
"autoload": {
  "psr-4": {
    "Util\\": "src/"
  }
}
```

Then run:

```
composer dump-autoload
```

✅ Usage
-------

[](#-usage)

```
use Util\Date;

// Get the current date and time as a Date object
echo Date::now();
// Output: 2025-07-17 09:00:00

// Create a Date object for a specific date
$date = new Date('2024-01-01');

// Subtract 3 days from the date
echo $date->days_ago(3);
// Output: 2023-12-29 00:00:00

// Add 2 months to the date
echo $date->months_from_now(2);
// Output: 2024-03-01 00:00:00

// 🔁 Chainable and expressive style

// 7 days ago from now
echo Date::now()->days(7)->ago();

// 1 month from now
echo Date::now()->months(1)->from_now();

// 🧰 Useful shortcuts

// Get yesterday's date
echo Date::yesterday();
// Output: 2025-07-16 00:00:00

// Get tomorrow's date
echo Date::tomorrow();
// Output: 2025-07-18 00:00:00
```

🧱 Class Reference
-----------------

[](#-class-reference)

### Constants

[](#constants)

- `Date::DEFAULT_DATETIME_FORMAT` – 'Y-m-d H:i:s'

### Static Methods

[](#static-methods)

- `Date::now($format)` – returns the current datetime

### Chainable Helpers

[](#chainable-helpers)

```
$date->years($n)->from_now();
$date->days($n)->ago();
```

### Relative Methods

[](#relative-methods)

- `days_ago($n)`
- `months_from_now($n)`
- `hours_ago($n)`
- `minutes_from_now($n)`
- ...and more!

📄 License
---------

[](#-license)

MIT © Ian Escarro

See LICENSE for details.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance59

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

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

Recently: every ~1 days

Total

8

Last Release

264d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/334216?v=4)[Ian](/maintainers/iescarro)[@iescarro](https://github.com/iescarro)

---

Top Contributors

[![iescarro](https://avatars.githubusercontent.com/u/334216?v=4)](https://github.com/iescarro "iescarro (15 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/iescarro-php-util/health.svg)

```
[![Health](https://phpackages.com/badges/iescarro-php-util/health.svg)](https://phpackages.com/packages/iescarro-php-util)
```

###  Alternatives

[mauricius/laravel-htmx

Laravel helper library for Htmx

363112.7k1](/packages/mauricius-laravel-htmx)[bodunde/geocoder

A laravel package that helps you with geocoding addresses and reverse geocoding coordinates using the google maps api. It also helps in calculating the distance between two locations using the Hervasine formula and the coordinates of the locations

247.7k](/packages/bodunde-geocoder)

PHPackages © 2026

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