Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Showing the time difference in a natural format? (Time::Duration)

by ikegami (Pope)
on Sep 21, 2008 at 21:39 UTC ( #712891=note: print w/ replies, xml ) Need Help??


in reply to Showing the time difference in a natural format?

I found Time::Duration

ago( $now - $then, 1 )

Caveats:

  • It simplifies by using year = 365 days and day = 24 hours.
  • It rounds instead of truncating.


Comment on Re: Showing the time difference in a natural format? (Time::Duration)
Download Code
Re^2: Showing the time difference in a natural format? (Time::Duration)
by skx (Parson) on Sep 21, 2008 at 21:48 UTC

    That looks ideal for me, even with the simplifications. ++

    Looking at the name I'm amazed I didn't find that myself.

    Steve
    --
      I searched for "time ago". Unfortunately, many time zones have "ago" in their name (such as "Chicago"). And it either ignored "ago" or it came up lots of irrelevant Time:: modules after those that had "time" and "ago" in their name.

      Update: Since I couldn't stop after the first sentence, the post lost all value. Ignore it :)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2015-07-03 03:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (48 votes), past polls