I want to display how many days and hours to a date using Carbon
, currently I got the code below.
Carbon::parse("2017-03-07 17:46:50")->diffForHumans()
It outputs:
6 days from now
I want it to output something like this:
6 days and 12 hours from now
How can I do that?
You can specify the level of details like this:
Carbon::parse("2017-03-07 17:46:50")->diffForHumans(['parts' => 6]);
You can use a value from 1 to 6. ( Doc )
Sorry I got this question today but here it is
$now = Carbon::now();
Carbon::parse("2017-03-07 17:46:50")->diffForHumans($now);
I hope it works and may help others.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.