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

johnk's avatar
Level 1

Change carbon date format

When I get the post date with the code below:

    $postDate = Post::where('id', $id)->first()->date;

It returns a carbon instance:

Carbon @1520523000 {#278 ▼
  date: 2018-06-20 15:30:00.0 UTC (+00:00)
}

But I want to have the date on this format "20/06/2018". Do you know how to get that from the returned carbon instance?

Also to get the current date with:

                $currentDate = date(now());

It shows: "2018-06-20 15:32:09". Do you know how to get also "20/06/2018" from the current date?.

0 likes
3 replies

Please or to participate in this conversation.