PHP code example of seiler / eloquent-date

1. Go to this page and download the library: Download seiler/eloquent-date 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/ */

    

seiler / eloquent-date example snippets


'providers' => [
    ...
    /*
     * Application Service Providers...
     */
    Jenssegers\Date\DateServiceProvider::class,
    ...
];

'aliases' => [
    ...
    'Date' => Jenssegers\Date\Date::class,
    ...
];



namespace App;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    use \Seiler\EloquentDate\EloquentDate;

    /**
     * The attributes that should be mutated to dates.
     *
     * @var array
     */
    protected $dates = [
        'created_at',
        'updated_at',
        'published_at',
    ];
}

\Jenssegers\Date\Date::setLocale('fr');

$post = Post::find(1);

echo $post->published_at->format('l j F Y H:i:s'); // samedi 19 mars 2016 21:58:16

echo $post->published_at->ago(); // il y a 1 jour