How can I make the variable minutes two digits?
I am trying to get the minutes to show two digits even though the definitive answer is assigned to the min_side variable. This is probably a simple answer, but I can't seem to get it to work.
def time_conversion(minutes)
hour = minutes/60
min_side = minutes%60
min_side = %02d
time = "#{hour}:#{min_side}"
return time
end
puts time_conversion(360)
+3
source to share
5 answers