Reputation: 3690
Is there a way I could get a result like this:
Date1 is 1 minute 2 hours 3 days 4 years away from Date2
in Laravel 5 + Carbon between two dates?
Upvotes: 1
Views: 2185
Reputation: 3690
It turned out Carbon::diffForHumans()
method exists.
Some code for the curious:
$date1 = new Carbon();
$diff = $date1->diffForHumans($date2);
print 'Date1 is ' + $diff . ' away from Date2';
// output
// "Date1 is 3 weeks away from Date2"
Upvotes: 3