PHP code example of ed9 / laravel-date-directive

1. Go to this page and download the library: Download ed9/laravel-date-directive library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ed9 / laravel-date-directive example snippets


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);
}

$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) . '!';
bash
php artisan vendor:publish --tag=date-time-directive