Reputation: 1901
I am working for notifications and i want to get notification created time in minutes . mean how earlier notification was created. difference of created date time and current date time in minuets this time i am getting just created date in my blade even not in minutes i want to get created at and current date time.
My blade view
<span class="time">{{ Carbon\Carbon::parse($notification->created_at)->format('d-m-Y') }}</span>
However i also have a method in my helper which gives me time in other format like 25 Dec 2017 which is also i am using at different places now i want difference in minutes for above time please help how can i do it
Upvotes: 3
Views: 5905
Reputation: 4135
If I understood you correctly:
Time in minutes
Carbon\Carbon::parse($notification->created_at)->diffInMinutes(Carbon\Carbon::now());
Else you should really just read the Carbon docs, they're incredibly extensive and contain an example for pretty much any use case: http://carbon.nesbot.com/docs/#api-difference
Upvotes: 3
Reputation: 163748
Use diffInMinutes()
method:
{{ $notification->created_at->diffInMinutes(Carbon::now()) }}
Note, that you don't need to parse created_at
as it's already an instance of Carbon.
Upvotes: 3