PHPackages                             sfneal/time-helpers - 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. sfneal/time-helpers

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

sfneal/time-helpers
===================

PHP time utilities for converting time values &amp; creating time periods

1.2.3(4y ago)06.0k1MITPHPPHP &gt;=7.3

Since Aug 21Pushed 4y ago1 watchersCompare

[ Source](https://github.com/sfneal/time-helpers)[ Packagist](https://packagist.org/packages/sfneal/time-helpers)[ Docs](https://github.com/sfneal/time-helpers)[ RSS](/packages/sfneal-time-helpers/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (5)Versions (24)Used By (1)

Time Helpers
============

[](#time-helpers)

[![Packagist PHP support](https://camo.githubusercontent.com/11b001b44cfc34a05b127fc5a11e475e0ee31fe8022c57a7d6d6045c95abbf47/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f73666e65616c2f74696d652d68656c70657273)](https://packagist.org/packages/sfneal/time-helpers)[![Latest Version on Packagist](https://camo.githubusercontent.com/6532f3d6a8ebbd8e82d0275db065f9a5a8f36a809f3a8d46dd8aa045c823241b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73666e65616c2f74696d652d68656c706572732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sfneal/time-helpers)[![Build Status](https://camo.githubusercontent.com/ea4dc2b52705f9185b895702b76c92d45b5303e0068f3a8369597342338fe01f/68747470733a2f2f7472617669732d63692e636f6d2f73666e65616c2f74696d652d68656c706572732e7376673f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://travis-ci.com/sfneal/time-helpers)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/956298e714684fd20e289f8aec3b657ff89fa777e5f23098ba299bb3eb7a337d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73666e65616c2f74696d652d68656c706572732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/sfneal/time-helpers/?branch=master)[![StyleCI](https://camo.githubusercontent.com/c4d40509e1e22d7bc7cac24f7d65f5772c62868afa5ec7c970561a509f3eb8c9/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3238393332383935342f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/289328954?branch=master)[![Total Downloads](https://camo.githubusercontent.com/22a2d1fe4d576af292a4e68e7fe212a75e84a9a9e3cf5195636019f4658065c0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73666e65616c2f74696d652d68656c706572732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sfneal/time-helpers)

PHP time utilities for converting time values &amp; creating time periods

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

[](#installation)

You can install the package via composer:

```
composer require sfneal/time-helpers
```

Usage
-----

[](#usage)

### Carbonate

[](#carbonate)

Carbonate can be used to retrieve Carbon objects transformed from today's datetime. This is useful for getting a Carbon object that represents a datetime in the past or future.

```
use Sfneal\Helpers\Time\Carbonate;

// Retrieve a Carbon\Carbon object representing '3' days ago
$threeDaysAgo = Carbonate::daysAgo(3);
$threeDaysAgo = Carbonate::days(-3);

// Retrieve a Carbon\Carbon object representing '5' years ago
$fiveYearsAgo = Carbonate::yearsAgo(3);
$fiveYearsAgo = Carbonate::years(-3);

// Retrieve a Carbon\Carbon object representing '6' months ago
$sixMonthsAgo = Carbonate::monthsAgo(3);
$sixMonthsAgo = Carbonate::months(-3);
```

### TimeConverter

[](#timeconverter)

TimeConverter is used to convert between different units of time (hours, minutes &amp; seconds).

```
use Sfneal\Helpers\Time\TimeConverter;

// Convert Hours to Minutes
$hours = 5.5;
$minutes = (new TimeConverter())->setHours($hours)->minutes();
>>> 19800

// Convert Seconds to Hours
$seconds = 37800;
$hours = (new TimeConverter())->setSeconds($hours)->hours();
>>> 10.5
```

### TimePeriod

[](#timeperiod)

TimePeriod is used to retrieve a start &amp; end datetime for a period of time (like today, last month, etc). This can be useful when creating time scoped queries, like collecting all the orders from last month.

```
use Sfneal\Helpers\Time\TimePeriod;

// Retrieve a TimePeriod representing today (02/16/2021)
[$start, $end] = TimePeriods::today();
// $start >>> 2021-02-16 00:00:00
// $end >>> 2021-02-16 23:59:59
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Stephen Neal](https://github.com/sfneal)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

PHP Package Boilerplate
-----------------------

[](#php-package-boilerplate)

This package was generated using the [PHP Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

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

Recently: every ~30 days

Total

22

Last Release

1747d ago

Major Versions

0.10.1 → 1.0.02021-02-16

PHP version history (5 changes)0.1.0PHP ^7.1

0.2.0PHP ^7.2

0.3.0PHP &gt;=7.0

0.7.1PHP &gt;=7.2

1.1.0PHP &gt;=7.3

### Community

Maintainers

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

---

Top Contributors

[![sfneal](https://avatars.githubusercontent.com/u/23200215?v=4)](https://github.com/sfneal "sfneal (145 commits)")

---

Tags

sfnealtime-helpers

### Embed Badge

![Health badge](/badges/sfneal-time-helpers/health.svg)

```
[![Health](https://phpackages.com/badges/sfneal-time-helpers/health.svg)](https://phpackages.com/packages/sfneal-time-helpers)
```

###  Alternatives

[bezhansalleh/filament-google-analytics

Google Analytics integration for FilamentPHP

205144.8k5](/packages/bezhansalleh-filament-google-analytics)

PHPackages © 2026

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