From: Steve Litt Date: 2005-12-14T23:09:53+09:00 Subject: Re: convert seconds to hours:minutes:seconds On Wednesday 14 December 2005 08:32 am, `p wrote: > Steve Litt wrote: > > On Wednesday 14 December 2005 05:21 am, Andy Delcambre wrote: > >>As long as you dont go past 24 hours you can use the Time > >> class: > >> > >>irb(main):016:0> Time.at(7683).gmtime.strftime('%R:%S') > >>=> "02:08:03" > > > > Next question: How do I get the number of seconds since Epoch? > > time.to_i > http://www.ruby-doc.org/core/classes/Time.html#M000196 Cool! Thanks! #!/usr/bin/ruby b4 = Time.new sleep(3) after = Time.new interval = after.to_i - b4.to_i print "Started at ", b4.asctime, ", ended at ", after.asctime print "\n Interval is ", interval.to_s, ".\n" SteveT Steve Litt http://www.troubleshooters.com slitt@troubleshooters.com