How to display diffrence only by days. Here $price->created_at = 2014-04-28
\Carbon\Carbon::createFromTimeStamp(strtotime($price->created_at))->diffForHumans()
Thanks!
You can only use the diffInDays() function on a Carbon instance. You can create a new one by parsing the end date you're receiving. $end = Carbon::parse($request->input('end_date'));
Carbon::parse($client->db)->format('d/m/y'); is probably what you're wanting. (parse the yyyy-mm-dd date in the database as a date, and convert it to d/m/y format).
Suppose you want difference to now() and result from diffForHumans suits you except for today:
$created = new Carbon($price->created_at); $now = Carbon::now(); $difference = ($created->diff($now)->days < 1) ? 'today' : $created->diffForHumans($now);
edit: no need to call Carbon::now() twice so use $now instead.
diffInDays function would help.
$cDate = Carbon::parse($date); return $cDate->diffInDays();
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