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/ */
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
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.