You can use time formatting: Time # strftime
t1 = Time.now t2 = Time.new(2012, 12, 12) t1.strftime "The time is %H:%M"
Alternatively, you can use string formatting with the '%' operator
t1 = Time.now t2 = Time.new(2012, 12, 12) "The time is %02d:%02d" % [t1.hour, t1.min]
Sergio Tulentsev
source share