Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Seconds conversion

by ckohl1 (Hermit)
on Jul 08, 2002 at 18:15 UTC ( [id://180256]=note: print w/replies, xml ) Need Help??


in reply to Seconds conversion

I am not sure about a standard, but this idea may work:
#!/usr/bin/perl use strict; print "${\SecondsToTime(22)}\n"; print "${\SecondsToTime(220)}\n"; print "${\SecondsToTime(2200)}\n"; print "${\SecondsToTime(22000)}\n"; exit; sub SecondsToTime { # Takes a number of seconds, and creates a string in the 'dd hh:mm +:ss' format. my ( $time ) = shift; $time = int( $time ); my $newTime = sprintf( "%.2d ", int($time / 86400) ); $newTime .= sprintf( "%.2d", int(($time % 86400) / 3600) ); $newTime .= ':' . sprintf( "%.2d", int(($time % 3600) / 60) ); $newTime .= ':' . sprintf( "%.2d", int(($time % 3600) % 60) ); return ( $newTime ); }


Chris

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://180256]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-03-28 20:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found