PHPackages                             ed9/laravel-date-directive - 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. ed9/laravel-date-directive

ActiveLibrary

ed9/laravel-date-directive
==========================

Simplify the date &amp; time handling when in need to show date &amp; time to customer in their timezone.

1.0.2(2y ago)5223↓100%MITPHP

Since Nov 7Pushed 2y ago1 watchersCompare

[ Source](https://github.com/ed9/laravel-date-directive)[ Packagist](https://packagist.org/packages/ed9/laravel-date-directive)[ RSS](/packages/ed9-laravel-date-directive/feed)WikiDiscussions master Synced 1mo ago

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

Laravel Date Directive
======================

[](#laravel-date-directive)

Overview:
---------

[](#overview)

Laravel Date Directive is a comprehensive Laravel library designed to address persistent challenges related to site content, user interactions, and regional settings. It facilitates the seamless presentation of date and time elements based on user timezones. This library extends on-top of the [laravel-readable](https://github.com/Pharaonic/laravel-readable) library.

Installation:
-------------

[](#installation)

To integrate the library into your Laravel project, use Composer:

```
composer require ed9/laravel-date-directive
```

Configuration:
--------------

[](#configuration)

To customize the library behavior, publish the configuration file:

```
php artisan vendor:publish --tag=date-time-directive
```

### Configuration options include:

[](#configuration-options-include)

KeyTypeDescriptionalways\_show\_secondsbooleanWhen the library outputs time, it includes seconds if set to true.timezonestringA valid timezone name; refer to the list of [supported timezones](https://www.php.net/manual/en/timezones.php).string\_formatstringSupports \\Carbon\\Carbon or string input; if string is used, it must match the configured format.use\_12\_hour\_clockbooleanWhen the library outputs time, it displays the time in 12-hour format if set to true, or 24-hour format if set to false.Setup:
------

[](#setup)

Configure the system default settings in the configuration file. Optionally, configure per-user settings by adding timezone and other configuration items to your users table. Update the \\App\\Http\\Middleware\\Authenticate::class by extending the boot method, overriding the library configuration during runtime.

```
public function handle($request, Closure $next, ...$guards)
{
    if ($user = auth()->user()) {
        $handler = app(\Ed9\LaravelDateDirective\Handler::class);
        $handler->set12HourFormat($user->show_time_with_12_hours);
        $handler->setTimezone($user->timezone);
    }

    return parent::handle($request, $next, ...$guards);
}
```

Usage:
------

[](#usage)

### In Blade Templates:

[](#in-blade-templates)

DirectiveArgumentsOutput@time\\Carbon\\Carbon, stringOutputs the time of the input in the configured timezone.@date\\Carbon\\Carbon, stringOutputs the date of the input in the configured timezone.@dateTime\\Carbon\\Carbon, stringOutputs the date and time of the input in the configured timezone.#### Example:

[](#example)

```
User {{ $user->name}} was created at @time($user->created_at) on @date($user->created_at).
Some might say, this was on @dateTime($user->created_at)!
```

### In PHP Code:

[](#in-php-code)

If you need access to the formatted and converted values in your PHP code, use the \\Ed9\\LaravelDateDirective\\Handler:

```
$handler = app(\Ed9\LaravelDateDirective\Handler::class);
echo 'User ' . $user->name . ' was created at ' . $handler->time($user->created_at).' on '.$handler->date($user->created_at) . '.';
echo 'Some might say, this was on ' . $handler->dateTime($user->created_at) . '!';
```

Available Methods via Handler:
------------------------------

[](#available-methods-via-handler)

- `set12HourFormat(boolean): self`: Configures the library to return time in 12 or 24-hour format.
- `setInputDateTimeFormat(string): self`: Configures the expected input format when calling directives using string values.
- `setTimezone(string): self`: Configures the timezone to which all output should be converted.
- `setUseSeconds(boolean): self`: Configures the library to return time with or without seconds.
- `time(\Carbon\Carbon|string): string`: Converts provided input into a time string in the configured timezone.
- `date(\Carbon\Carbon|string): string`: Converts provided input into a date string in the configured timezone.
- `dateTime(\Carbon\Carbon|string): string`: Converts provided input into a datetime string in the configured timezone.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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

Unknown

Total

1

Last Release

916d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/158f140da4baa952daa4333ef979db404da361058e4c1e76195d12775663207d?d=identicon)[ed9](/maintainers/ed9)

---

Top Contributors

[![ed9](https://avatars.githubusercontent.com/u/19610073?v=4)](https://github.com/ed9 "ed9 (1 commits)")[![travelfundcouk](https://avatars.githubusercontent.com/u/35568249?v=4)](https://github.com/travelfundcouk "travelfundcouk (1 commits)")

### Embed Badge

![Health badge](/badges/ed9-laravel-date-directive/health.svg)

```
[![Health](https://phpackages.com/badges/ed9-laravel-date-directive/health.svg)](https://phpackages.com/packages/ed9-laravel-date-directive)
```

###  Alternatives

[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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