[ create a new paste ] login | about

Link: http://codepad.org/KNj44By5    [ raw code | output | fork ]

PHP, pasted on Oct 6:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
$in = strtotime("2011-10-02 23:00:00");
$out = strtotime("2011-10-05 23:00:00"); // 72 hours apart

$elapsed = $out - $in;

$hours = floor($elapsed / 3600);
$minutes = floor(($elapsed / 60) % 60);
   if (strlen($minutes) == "1") { $minutes = $minutes."0"; } // No single digits

$seconds = round(($elapsed / (3600)) % 60);
   if (strlen($seconds) == "1") { $seconds = $seconds."0"; } // No single digits

$total = $hours.":".$minutes.":".$seconds; // Should be 72:00:00

echo $total
?>


Output:
1
72:00:12


Create a new paste based on this one


Comments: