[ create a new paste ] login | about

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

chriszuma - 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:02:03"); // 72 hours apart

$elapsed = $out - $in;

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

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

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

echo $total
?>


Output:
1
72:02:03


Create a new paste based on this one


Comments: