From: Andy Delcambre Date: 2005-12-14T19:21:22+09:00 Subject: Re: convert seconds to hours:minutes:seconds 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" If you dont use gmtime, it will go based off your localtime, where the epoch = the offset from GMT. also by doing the arithmatic: irb(main):023:0> time = 7683 => 7683 irb(main):024:0> hours = time/3600.to_i => 2 irb(main):025:0> minutes = (time/60 - hours * 60).to_i => 8 irb(main):026:0> seconds = (time - (minutes * 60 + hours * 3600)) => 3 irb(main):030:0> printf("%02d:%02d:%02d\n", hours, minutes, seconds) 02:08:03 => nil HTH - Andy Delcambre On 12/14/05, `p wrote: > hello! > i am trying to convert a number of seconds to a nicely formatted string > like this: > > 7683 seconds = 02:08:03 > > is there an easy way to accomplish this? > >