From: Chris Pine Date: 2005-12-14T19:13:54+09:00 Subject: Re: convert seconds to hours:minutes:seconds 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 Well, assuming you know how to arithmetic, conversions, and string concatenation (and if not, check out http://pine.fm/LearnToProgram/), all you're missing is how to pad with zeroes. I do talk about the rjust method, but not that you can use it to pad with things other than spaces: 2.to_s.rjust(5,'0') This pads the string '2' (from 2.to_s) with the string '0'. Another, fancier (or just more complicated? :) way: irb(main):001:0> '%.5d' % 2 => "00002" Hope that helps, Chris