date() should not be used to express duration
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Nagios Visual Shell |
New
|
Undecided
|
Unassigned |
Bug Description
the function calculate_duration, in read_status.php uses duration to evaluate the result of one timestamp being subtracted to another.
The result is actually a date early in the unix epoch, which I don't think is the intended effect.
I've adapted the function code below, and the output to exemplify the problem.
<?php
$beginning = '1295908827';
$now = time();
$duration = ($now - $beginning);
$duration_
print("Duration of outage in minutes: $duration_
$original_duration = date('d\
$epoch_duration = date('r', $duration);
print("Date in unix epoch format: $epoch_duration <br/>");
print("duration as it shows up in vshell: $original_duration <br/>");
?>
Here is what I get in my browser, after running it on my server:
Duration of outage in minutes: 213.01666666667
Date in unix epoch format: Wed, 31 Dec 1969 22:33:01 -0500
duration as it shows up in vshell: 31d-22h-33m-01s
What you need is something like the code here, but I'm not sure what the licensing terms for this site are.