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

rojonunoo's avatar

Converting Date values to Text

i have a set of date values like "Y/m/d" stored in my DB i want to the output to read in text like Jan.17.2017 to view how do i go about that

0 likes
2 replies
spekkionu's avatar

If you add the field to the $dates property on your model it will automatically converted to a Carbon instance when fetched from the database (which extends the core DateTime class).

You can then use the format method on it when echoing it to format it however you want.

In your example it would be something like

$model->field->format('M.j.Y')
2 likes

Please or to participate in this conversation.