Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Converting Seconds to Nice Format

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


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 07: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
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-12-08 10:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which IDE have you been most impressed by?













    Results (50 votes). Check out past polls.