PHPackages                             joshbrw/laravel-contextual-dates - 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. joshbrw/laravel-contextual-dates

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

joshbrw/laravel-contextual-dates
================================

Contextual date functionality in Laravel.

v0.1.4(8y ago)02.9kMITPHP &gt;=5.6

Since Mar 20Compare

[ Source](https://github.com/joshbrw/laravel-contextual-dates)[ Packagist](https://packagist.org/packages/joshbrw/laravel-contextual-dates)[ RSS](/packages/joshbrw-laravel-contextual-dates/feed)WikiDiscussions Synced yesterday

READMEChangelogDependencies (2)Versions (6)Used By (0)

Laravel Contextual Dates
========================

[](#laravel-contextual-dates)

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

[](#installation)

1. Install the package via Composer: `composer require joshbrw/laravel-contextual-dates`
2. Add the Service Provider to `config/app.php`: `Joshbrw\LaravelContextualDates\ContextualDatesServiceProvider::class`
3. Configure the `DateTimeFactory` with the desired Timezone and Formats. These formats can be named whatever you like, i.e. `long` or `short`.
4. Use the `FormatsDates` trait or the helpers defined in `helpers.php` to localize/output the dates.

Defaults
--------

[](#defaults)

Two date formats are provided by default, `long` and `short`. These can be over-ridden at any time.

Examples
--------

[](#examples)

### Using Container

[](#using-container)

The `DateTimeFactory` is bound as a singleton in the container, so it can be picked up and modified at any time (similar to the inbuilt View/Validation factories that Laravel provides).

```
$dateTimeFactory = app(DateTimeFactory::class);
$dateTimeFactory->addFormat('mixed', 'Y-m-d');

$carbon = new \Carbon\Carbon;

$dateTime = $dateTimeFactory->createFromCarbon($carbon);

echo $dateTime->format('mixed'); /* Outputs in Y-m-d */
```

### Using Helpers

[](#using-helpers)

This package ships with two helper methods; `localize_date()` and `format_date()`.

```
$dateTimeFactory = app(DateTimeFactory::class);
$dateTimeFactory->addFormat('mixed', 'Y-m-d');

$carbon = new \Carbon\Carbon;

$instance = localize_date($carbon); /* Instance of DateTime */

echo format_date($carbon, 'mixed'); /* Outputs in Y-m-d */
```

### Using Blade Directive

[](#using-blade-directive)

You can format dates in the Views using the Blade Directive. All this does is proxy to the `format_date()` helper method.

```
@date(new Carbon, 'long')
```

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

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

Total

5

Last Release

3211d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/779766?v=4)[Josh Brown](/maintainers/joshbrw)[@joshbrw](https://github.com/joshbrw)

### Embed Badge

![Health badge](/badges/joshbrw-laravel-contextual-dates/health.svg)

```
[![Health](https://phpackages.com/badges/joshbrw-laravel-contextual-dates/health.svg)](https://phpackages.com/packages/joshbrw-laravel-contextual-dates)
```

###  Alternatives

[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.1k91.3M283](/packages/laravel-horizon)[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k8.7M64](/packages/spatie-laravel-responsecache)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[flarum/core

Delightfully simple forum software.

201.4M2.2k](/packages/flarum-core)[erlandmuchasaj/laravel-gzip

Gzip your responses.

40140.4k2](/packages/erlandmuchasaj-laravel-gzip)

PHPackages © 2026

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