PHPackages                             davealex/laravel-time-period-reference - 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. davealex/laravel-time-period-reference

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

davealex/laravel-time-period-reference
======================================

A service for processing string-based time references into carbon instances

v1.0.9(6mo ago)16MITPHPPHP ^8.3.0CI passing

Since Mar 8Pushed 6mo ago1 watchersCompare

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

READMEChangelog (10)Dependencies (2)Versions (10)Used By (0)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4eabb5d45cc89fe6778ee7edb05956a77d07ffe1949045d0c5cefa5cae7ea116/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64617665616c65782f6c61726176656c2d74696d652d706572696f642d7265666572656e63652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/davealex/laravel-time-period-reference)[![Total Downloads](https://camo.githubusercontent.com/a6c5d9e4284b7a2093767bf78f3c132986c7a11402334bc1d6a50def3c999411/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64617665616c65782f6c61726176656c2d74696d652d706572696f642d7265666572656e63652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/davealex/laravel-time-period-reference)[![run-tests](https://github.com/davealex/laravel-time-period-reference/actions/workflows/main.yml/badge.svg)](https://github.com/davealex/laravel-time-period-reference/actions/workflows/main.yml)

**Laravel Time Period Reference**
=================================

[](#laravel-time-period-reference)

A clean, flexible utility package for Laravel that converts natural-language time period references **(e.g., "3 hours ago", "1 week")** into precise **Carbon instances**.

This is ideal for handling user inputs, API requests, or configuration values that define a time window relative to `now()`. It supports custom units and integrates seamlessly with **PHP 8.1+ Enums**.

**1. Installation**
-------------------

[](#1-installation)

You can install the package via Composer:

`composer require davealex/laravel-time-period-reference`

**2. Configuration**
--------------------

[](#2-configuration)

By default, the package supports common references (seconds, minutes, days, weeks, etc.). To customize or extend these references, publish the configuration file:

`php artisan vendor:publish --provider="Davealex\LaravelTimePeriodReference\LaravelTimePeriodReferenceServiceProvider" --tag="config"`

This creates `config/laravel-time-period-reference.php`.

### **Example Configuration (config/laravel-time-period-reference.php)**

[](#example-configuration-configlaravel-time-period-referencephp)

The array keys correspond to the standard **Carbon method name** (e.g., `subDays`, `subWeeks`), and the values are the acceptable string references.

```
