Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

artonico's avatar

Getting Date Difference Since Created_At

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 !!

0 likes
2 replies
tykus's avatar
tykus
Best Answer
Level 104

@foreach($transaction->comments as $comment) //some views

Date Differences : {{ $comment->created_at->diffForHumans() }}

@endforeach

Please or to participate in this conversation.