Level 104
@foreach($transaction->comments as $comment) //some views
Date Differences : {{ $comment->created_at->diffForHumans() }}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello.
I need to get a date difference since the created_at until today. I know that i can use carbon for it but i don't know the exact syntax or the correct way to do the whole calculations. I tried doing something like this :
@foreach($transaction->comments as $comment)
//some views
Date Differences : {{ \Carbon\Carbon::now()->$comment->createdAt->diffForHumans() }}
@endforeach
But it just returned the comment Model, not the createdAt value which i intended...
Any help is really appreciated !!
@foreach($transaction->comments as $comment) //some views
Date Differences : {{ $comment->created_at->diffForHumans() }}
Please or to participate in this conversation.