PHP code example of torzer / laravel-datetime-mutator

1. Go to this page and download the library: Download torzer/laravel-datetime-mutator 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/ */

    

torzer / laravel-datetime-mutator example snippets




use Torzer\Common\Traits\MapDateTimeMutator;

class MyClass extends Model {

    use MapDateTimeMutator;
..



use Torzer\Common\Traits\MapDateTimeMutator;

class MyClass extends Model {

    use MapDateTimeMutator;

    protected $mapDateTimeMutator = [
        'start_date' => ['from' => 'd/m/Y', 'to' => 'Y-m-d'],
        'finish_date' => ['from' => 'd/m/Y', 'to' => 'Y-m-d']
    ];

    protected $dates = [
        'approved_at', 'start_date', 'finish_date'
    ];

    ...





use Torzer\Common\Traits\MapDateTimeMutator;

class MyClass extends Jenssegers\Mongodb\Eloquent\Model {

    use MapDateTimeMutator;

    protected $mapDateTimeMutator = [
        'start_date' => ['from' => 'd/m/Y', 'to' => 'Y-m-d'],
        'finish_date' => ['from' => 'd/m/Y', 'to' => 'Y-m-d'],
        'date-only' => true,
    ];

    protected $dates = [
        'approved_at', 'start_date', 'finish_date'
    ];

    ...