eval.in

Paste #117021

PHP — PHP 5.4.6, pasted 5 years ago (json)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
<?php

$estimated_times = array(
  5,
  20,
  35,
  110
);

$current_time = time(); // seconds since unix epoch
    echo 'Start: ' . date('h:i:s') . PHP_EOL;
    
foreach($estimated_times as $estimated_time) {
        $current_time += $estimated_time;
        echo 'Estimated time: ' . $estimated_time . ' seconds: ' . date('h:i:s', $current_time) . PHP_EOL;
    }

Program Output

Start: 09:11:08
Estimated time: 5 seconds: 09:11:13
Estimated time: 20 seconds: 09:11:33
Estimated time: 35 seconds: 09:12:08
Estimated time: 110 seconds: 09:13:58

OK (0.004 sec real, 0.006 sec wall, 13 MB, 48 syscalls)

Fork