So the math?
$totalDays = \Carbon\Carbon::parse('2022-03-04')->diffInDays(\Carbon\Carbon::parse('2023-01-04'));
$daysLeft = now()->diffInDays(\Carbon\Carbon::parse('2023-01-04'));
$percentage = round(($totalDays - $daysLeft) / $totalDays * 100, 2);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello, I want to create a progress bar that will count days for the next approximate delivery date. It will take its start date=Today's Date, and count the next days complete the progress bar. Example: start = 9/9/2022 End/max = Next 283 days. when it is complete 283 days then the progress bar should be 100% and make a reminder for the delivery.
Can anyone help me with these?
@zahedalam Just in case it wasnt clear. My example gives two dates. These are expected to be gotten from the database.
$totalDays = \Carbon\Carbon::parse($delivery->sent_date)->diffInDays(\Carbon\Carbon::parse($delivery->expected_delivery_date));
$daysLeft = now()->diffInDays(\Carbon\Carbon::parse($delivery->expected_delivery_date));
$percentage = round(($totalDays - $daysLeft) / $totalDays * 100, 2);
Please or to participate in this conversation.