Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

fatima1's avatar

change date format

hi all i have data in json formt

[
{"id":4,
"title":"title",
"description":"hi there",
"created_at":"2018-12-11 22:11:01"}
]

i want to change date format to 11/12/2018

how to do that??

0 likes
8 replies
manelgavalda's avatar

The created_at field is a Carbon instance, so when you are returning your json you can so this:

'created_at' => $model->created_at->format('d/m/Y');
knubbe82's avatar
$reference->created_at->format('d/m/Y');
munazzil's avatar

Use as like below

                $json->created_at->format('dd/mm/yyyy');
fatima1's avatar
fatima1
OP
Best Answer
Level 1

this it doesnt work because its in json (string), it doesnt allow me to change it

  $json->created_at->format('dd/mm/yyyy');

SO, i use javascript to change the format

1 like

Please or to participate in this conversation.