Answers for "laravel format date from y-m-d"

PHP
1

date casting from datetime to d-m-Y laravel

/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
   'created_at' => 'datetime:Y-m-d',
   'updated_at' => 'datetime:Y-m-d',
   'deleted_at' => 'datetime:Y-m-d h:i:s'
];
Posted by: Guest on August-29-2021
0

laravel 8 date format

// in model 
protected $casts = [
        'date_of_approval' => 'date:d-m-Y'
    ];

// if you want change format any where
$appointment->date_of_approval->format('Y-m-d');

// if you have not cast in model data format
Carbon\Carbon::parse($appointment->date_of_approval)->format('Y-m-d');
Posted by: Guest on January-04-2022

Code answers related to "laravel format date from y-m-d"

Browse Popular Code Answers by Language