How to get 2 digit hour and minutes from Rails time class
It might be worth looking into Time#strftime if you're wanting to put your times together into a readable string or something like that.
For example,
t = Time.now
t.strftime('%H')
#=> returns a 0-padded string of the hour, like "07"
t.strftime('%M')
#=> returns a 0-padded string of the minute, like "03"
t.strftime('%H:%M')
#=> "07:03"
How about using String.format (%) operator? Like this:
x = '%02d' % t.hour
puts x # prints 07 if t.hour equals 7