Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
laziness, impatience, and hubris
 
PerlMonks  

Re: Converting Seconds to Nice Format

by Anonymous Monk
on Nov 12, 2000 at 00:56 UTC ( [id://41137]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Converting Seconds to Nice Format

Something like this:
$up = `cat /proc/uptime`; $up =~ m/[^ .]*/; $upseconds = $&; $days = (int($upseconds / (60*60*24))) % 7; $hours = (int($upseconds / (60*60))) % 24; $minutes = (int($upseconds / 60)) % 60; $weeks = (int($upseconds / (60*60*24*7))) % 52; $years = (int($upseconds / (60*60*24*365))) % 10; $decades = (int($upseconds / (60*60*24*365*10)));

Replies are listed 'Best First'.
RE: Re: Converting Seconds to Nice Format
by blogan (Monk) on Nov 12, 2000 at 02:23 UTC
    Your code looks file, but I would suggest that you may want to reorder the lines so it looks a little better.
    $up = `cat /proc/uptime`; $up =~ m/[^ .]*/; $upseconds = $&; $seconds = (int($upseconds)) % 60; $minutes = (int($upseconds / (60))) % 60; $hours = (int($upseconds / (60*60))) % 24; $days = (int($upseconds / (60*60*24))) % 7; $weeks = (int($upseconds / (60*60*24*7))) % 52; $years = (int($upseconds / (60*60*24*365))) % 10; $decades = (int($upseconds / (60*60*24*365*10)));

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://41137]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.