Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: How do I convert seconds into a readable time?

by zen-japh (Initiate)
on Aug 03, 2001 at 21:51 UTC ( [id://102065]=note: print w/replies, xml ) Need Help??


in reply to How do I convert seconds into a readable time?

Here is a method of going back to seconds from a string like "2 days, 6 hours, 32 minutes and 44 seconds":
sub dhms2sec { my $in = shift; $in =~ s/(and|,)//g; $in =~ s/(\w+)s/\1/g; my %y = reverse split(/\s+/,$in); return ($y{'second'}) + ($y{'minute'} * 60) + ($y{'hour'} * 60*60) + ($y{'day'} * 60*60*24); }

Replies are listed 'Best First'.
Re: Answer: How do I convert seconds into a readable time?
by blakem (Monsignor) on Aug 04, 2001 at 04:03 UTC
    The answer and question don't match.... The question is "How do I convert seconds into a readable time?" but the answer given converts readable time into seconds...

    Q: How do I '$seconds => $string'??
    A: Do this '$string => $seconds'!!

    We should change one or the other to get them to match.

    -Blake

    Update After a bit more investigating, I decided that this isn't really an issue. I thought it was the only answer given for the question. Since it is more of a "thats cool, here's how you can do it backwards" post, my complaint isn't really valid. Feel free to remove this node, mr reaper...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-19 20:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found