Here's one way:

$delta = 264200;
$daysPassed = int($delta / 86400);
$deltaDays = $delta % 86400;
$hoursPassed = int($deltaDays / 3600);
$deltaHours = $deltaDays % 3600;
$minsPassed = int($deltaHours / 60);
$deltaMins = $deltaHours % 60;
$secsPassed = $delta;
$deltaSecs = $deltaMins % 60;

print "$daysPassed Days, $hoursPassed Hours, $minsPassed Minutes, and
$secsPassed Seconds have passed.";

That will work up to weeks.  If you need to calculate months you will have
to look into Date::Manip or Date::Calc.


-----Original Message-----
From: dan [mailto:perl@;danneh.demon.co.uk]
Sent: Wednesday, November 13, 2002 12:41 PM
To: [EMAIL PROTECTED]
Subject: uptime


how may it be possible to say how long it was before a certain time?
say for instance i have the variable
$starttime = time();
then, later an uptime was called. the time of the uptime being
$timenow = time();
$runningtime = $runningtime - $timenow;
now i have the amount of time the program has been running in seconds, but
how do i convert that to days, hours, mins, secs, etc..?

dan



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to