I need format a string date in Laravel
My date is like 2021-05-25
I need format this to 25/05/2021
using Carbon
CodePudding user response:
You can use
use \Carbon\Carbon;
$birth = Carbon::createFromFormat('d/m/Y', '28/01/1994');
echo $birth->format('d/m/Y');
CodePudding user response:
you can use like this:
use \Carbon\Carbon;
$birth = Carbon::createFromFormat('d/m/Y', '28/01/1994');
echo $birth->format('d/m/Y');
CodePudding user response:
Use this code:
use Carbon\Carbon;
$myDate = '2021-05-25';
$result = Carbon::createFromFormat('d/m/Y', $myDate)->format('Y-m-d');
echo $result;