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

zahedalam's avatar

Create a Progress bar for generate approximate delivery Date

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?

0 likes
10 replies
Sinnbeck's avatar

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);
zahedalam's avatar

@Sinnbeck I want to create it dynamically.. day after it will count and the progress bar will increase an dafter 283 days it will be 100%. Then may i need to use jquery?

Sinnbeck's avatar

@zahedalam And how is what I wrote not dynamic? I use now() to get the days left, so every day it changes.

You put the thread in laravel, so I assumed you wanted it in php

1 like
zahedalam's avatar

@Sinnbeck can u please tell me how can I get the date after 283 days from today? I want the date actually.. after 283 days

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@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);
1 like

Please or to participate in this conversation.