Support the ongoing development of Laravel.io →
Configuration Eloquent
Last updated 2 years ago.
0

setToStringFormat() works here for all model dates, default or custom. Not sure what goes wrong on your end. Eloquent model shouldn't really change the output of the carbon object, only creates it for date fields.

ps.: You should use a base model, so you don't have to modify in every model in similar cases.

Last updated 2 years ago.
0

Hi Sam, i am having similar trouble,

i have registered it as an alias in the app config file, but still no luck.

carbon functions perfectly in any other way but where ever i use

Carbon::setToStringFormat('d/m/Y');

it dosn't seem to work

Cheers

Oli

Last updated 2 years ago.
0

i seem to have made a bit of progress on this,

that carbon output is only provided by the model when you specifically access the date field:,

$modelName->dateField.

if you just dump the query response straight into an array and output it as json the carbon conversion is never called.

Oli

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.