I'm trying to implement a comment section in my project and want to show how long ago the comment was posted.
So i did:
{{ $comment->created_at->diffForHumans() }}
And the output was
3 hours from now
But the output that i want is
3 hours ago
Am i missing something ? I'm doing this in laravel
You can use, this $comment->created_at->diffForHumans(null, true)
to remove the ago,from now, etc
then you can append the ago by yourself . So you'll end up with:
$comment->created_at->diffForHumans(null, true).' ago'
(NB: you may need to check why this does not work by default)
Ref: https://carbon.nesbot.com/docs/#api-humandiff
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With