I'm building a queue to generate something and I want it visible for users to see how long it will take till the generation is ready.
So I have an estimated time it takes to generate something, but that is a variable because it can be anywhere between 5-120 seconds. And now I need to add the variable time to the time of the day and make a loop because the queue has more values.
So for example I need this:
Object 1 - Estimated generation time: 15 sec - 09:00:15
Object 2 - Estimated generation time: 20 sec - 09:00:35
Object 3 - Estimated generation time: 10 sec - 09:00:45
And so on..
I already tried this:
$my_time = date('h:i:s',time());
$seconds2add = $estimated_time;
$new_time= strtotime($my_time);
$new_time+=$seconds2add;
echo date('h:i:s',$new_time);
And:
$time = date("m/d/Y h:i:s a", time() + $estimated_time);
It loops but both gives me like this output:
Object 1 - Estimated generation time: 15 sec - 09:00:15
Object 2 - Estimated generation time: 20 sec - 09:00:20
Object 3 - Estimated generation time: 10 sec - 09:00:10
So how can I make it loop that it works?
Edit: This is my loop
$this_time = date('h:i:s',time());
$my_time = $this_time;
$num = 1;
foreach($orders as $order) {
echo '<tr>'
. '<td>'.($num++).'</td>'
. '<td>'. $order->url .'</td>'
. '<td>'. $order->product_desc .'</td>'
. '<td>'. $order->size .' cm</td>'
. '<td>'. $order->estimated_time .' sec</td>';
$seconds2add = $order->estimated_time;
$my_time= strtotime($my_time);
$my_time+=$seconds2add;
echo '<td>'. date('h:i:s',$my_time) . '</td>'
. '</tr>';
}