i want a progressbar to show the how much time completed between 2 given days, most probably i got answer but it doesn't work on some cases
Styles:
<style type="text/css">
#progressbar div
{
background-color: #99cc66;
width: 50%;
height: 20px;
border-radius: 10px;
}
</style>
case 1: working code
<?php
$date1 = strtotime("2014-09-05 11:44:01");
$date2 = strtotime("2014-09-07 12:44:01");
$today = time();
$num = $today - $date1;
$den = $date2 - $date1;
$percentage = ($today - $date1) / ($date2 - $date1) * 100;
?>
<?php if($percentage<100 && $percentage>=0){ ?>
<div id="progressbar" style="border: 1px solid ; border-radius: 10px;">
<div style="width: <?php echo $percentage; ?>%;"><span><?php echo round($percentage,2); ?>%</span></div>
</div>
<?php } ?>
case 2: not working
if i have to change the datetime format to 24 hours, i can't see the prgoressbar the $percentage is in negative values
<?php
$date1 = strtotime("2014-09-05 11:44:01");
$date2 = strtotime("2014-09-07 23:44:01");
$today = time();
$num = $today - $date1;
$den = $date2 - $date1;
$percentage = ($today - $date1) / ($date2 - $date1) * 100;
?>
<?php if($percentage<100 && $percentage>=0){ ?>
<div id="progressbar" style="border: 1px solid ; border-radius: 10px;">
<div style="width: <?php echo $percentage; ?>%;"><span><?php echo round($percentage,2); ?>%</span></div>
</div>
<?php } ?>
i want this progressbar work with the even 24hour format, any clue on this?