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

rajoyish's avatar

How to rounding up Carbon diffInDays to 1

Dear artisan, I am building a room booking system, I need to calculate days based on check in and check out days. The following code returns 0 if user chooses the same day. How can I round up to 1 ?

$check_in = Carbon::parse($request->check_in); // '2022-12-12'

$check_out = Carbon::parse($request->check_out); // '2022-12-12'

$days = $check_out->diffInDays($check_in); // 0
0 likes
2 replies

Please or to participate in this conversation.