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

lawkunchi's avatar

Changing laravel date format

I want to change laravel date format into something like this(22 Feb 2018)

0 likes
4 replies
Yamen's avatar
Yamen
Best Answer
Level 22

Timestamps ('created_at', 'updated_at') are actually Carbon instances, so you can format it as you want by format method like ->format('dd-mm-yyy') or maybe ->diffForHumans(), ->toDateString() or many more here:

https://carbon.nesbot.com/docs/#api-formatting

1 like
lawkunchi's avatar

Do I use this in the database table because it seems to be not working

$table->date('date')->toDateString();
tykus's avatar

@lawkunchi you are asking some very basic PHP and Laravel questions. It has been suggested a couple of times (at least) that you have a look at some of the free videos here to get up to speed with the basics. It would be worth the smalll investment of your time...

Dates in your database are typically stored as YYYY-MM-DD HH:mm:ss, you apply formatting on the PHP side, not in the migration.

Please or to participate in this conversation.