Reputation: 175
I have a progress bar that looks LIKE THIS
I also have a table for each user called time (which is a future expirey date. For example 1 day ahead, 1 week ahead... anything bigger than now).
I have made it so it calculates how many days, hours and minutes they have left until the time has been reached using the following code :
<?php
foreach($users as $user) {
$now = new DateTime();
$clientTime_console = $user[11]; $future_date_console = new DateTime($clientTime_console); $interval_console = $future_date_console->diff($now);
}
?>
Then I call this by using :
<?php foreach($users as $user) { echo $user[11] != '' ? $interval_console->format("<b>%a</b>d <b>%h</b>h <b>%i</b>m") : 'Not set'; } ?>
That works.
But then my progress bar. I want 100% to be the amount of time they originally were given and then for the progress bar to go down as their days pass.
I'm not sure how I would do this.
If I need another table or anything, could anyone let me know ?
Note that I add users or update users using my backend so I could possibly make a table called last-time-given
and then update it when I either add or update a users time.
My progress bar is this :
<div class="bar -info" style="width: 80%;"></div>
As you can see, it's done by the width so I would need to put in the style, a percentage.
Upvotes: 0
Views: 97
Reputation: 982
Have something like that:
<div class="bar -info" style="width:
<?php echo (strval($future_date_console->diff($now).s / $now->diff($total_time_allow).s)+"%");?>
;"></div>
If think you can adapt it to your need
Upvotes: 2