#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    1
    Rep Power
    0

    Arrow Time have passed.


    Hey there, I have asked this somewhere else but I will be asking here too:

    How do I know how much time have passed since a time object?
    I want a way to know how many seconds have passed?

    Code:
    $time = Time.now
    
    # I leave, and come back after 3 hours.
    # Now I want a method to return how much time have passed...
    # It should return "10800", the number of seconds passed.
    Thanks.
  2. #2
  3. No Profile Picture
    Brony & F/OSS Advocate
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2003
    Location
    Anaheim, CA (USA)
    Posts
    6,655
    Rep Power
    2476
    You can use a difference of clock values to determine the time your code ran:
    ruby Code:
    timeStart = Time.now
     
    # Run your code here....
     
     
    timeStop = Time.now
     
    puts (timeStart - timeStop) + " seconds have passed."
    Hope that helps.
    ~~ Peter ~~ :: ( Who am I? ) :: ( Peter's Musings: Uploading myself, bit by bit... ) :: ( Electronic Frontier Foundation ) :: ( I'm a GNU/Linux addict and Free Software Advocate. ) :: ( How to Ask Questions the Smart Way ) :: ( The Fedora Project, sponsored by Red Hat ) :: ( GNOME: The Free Software Desktop Project ) :: ( GnuPG Public Key ) :: ( About me on the WIki )
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2004
    Location
    Constant Limbo
    Posts
    989
    Rep Power
    363
    Originally Posted by codergeek42
    Code:
     (timeStart - timeStop)
    Of course, you would need to take the negative of that

    Code:
    timeStop - timeStart
    would do the trick.

    Comments on this post

    • codergeek42 agrees : Errr, yeah. Sorry for the slight confusion. XD
    True happiness is not getting what you want, it's wanting what you've already got.

    My Blog

IMN logo majestic logo threadwatch logo seochat tools logo