Gaming
We're here to keep you in the loop on all things gaming related.
Search
For scenarios where you require your dates in Laravel to be properly formatted in human readable form for your APIs. Here's the simple snippet you can use in your Model class.
/** * @return string */ public function getCreatedAtAttribute() { return Carbon::parse($this->attributes['created_at'])->diffForHumans(); } /** * @return string */ public function getUpdatedAtAttribute() { return Carbon::parse($this->attributes['updated_at'])->diffForHumans(); }
You can learn more about Laravel Accessors here.