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

That function is part of Carbon, which is what Eloquent uses for datetime fields.

https://github.com/briannesbitt/Carbon#api-humandiff

Last updated 2 years ago.
0

Eloquent timestamps are actually converted into instances of Carbon. diffForHumans() is a method from Carbon.

Last updated 2 years ago.
0

Just to add to the above: if you want your own model properties (database fields) to be converted into Carbon instances, add them to the Model's dates property. I detailed this on laravel-tricks.com:

http://www.laravel-tricks.com/tricks/model-date-mutators-an-easier-way

Last updated 2 years ago.
0

meigwilym said:

Just to add to the above: if you want your own model properties (database fields) to be converted into Carbon instances, add them to the Model's dates property. I detailed this on laravel-tricks.com:

http://www.laravel-tricks.com/tricks/model-date-mutators-an-easier-way

I didn't know that, thanks.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

apache123 apache123 Joined 3 Nov 2014

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.