Carbon Dates with Laravel Blade

Written by SarahS

23rd September 2019

If you have something like this:

{{ $task->created_at }}

and it comes out like:

2019-09-11 10:26:21

then use Carbon (which is already in Laravel):

{{ $task->created_at->diffForHumans() }}

and you’ll get:
1 week ago
instead.

Carbon:
https://carbon.nesbot.com/docs/#api-introduction

If this post helped you or if you have any questions please leave me a comment below:

0 Comments

You May Also Like…