I believe when retrieving a datetime value from your DB via Eloquent, the returned property would be a Carbon instance, and thus the following should work.
dd($d->format('dd/mm/Y'));
Best,
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello guys.
I retrieve some data from my database student_data table. The date of birth inside the table is 19/04/95. (The format is dd/mm/yy). The data is retrieved with this command:
$d = DB::table('student_data')->value('date_of_birth');
But testing with dd($d) gives me this result:
"1995-04-19 00:00:00"
How can I alter dd($d) result to show date as follows?
19/04/1995
Thanks in advance.
Pleasure man!
This line will return a string,
$d = DB::table('student_data')->value('date_of_birth');
Now lets overwrite $d with a Carbon instance from the string $d and reformat it like so,
$d = Carbon::createFromFormat('Y-m-d H:i:s', $d)->format('d/m/Y');
Then you can pass $d to the view/blade as before,
...['mydate' => $d]...
Then in blade you can do,
{{ $mydate }}
Please or to participate in this conversation.