How do I convert \"11am\" and \"10pm\" into \"11:00\" and \"22:00\"? Is there a simple way using the date and time classes?
Are you saying you want 11am and 10pm and then the ability to 11:00 and 22:00 or do you want how to show 11:00 and 22:00 instead of 11am and 10pm?
if its the second question here:
%H - Hour of the day, 24-hour clock (00 to 23).
#!/usr/bin/ruby -w
time = Time.new
puts time.to_s
puts time.ctime
puts time.localtime
puts time.strftime("%H:%M")
if its the first question tell:
%I Hour of the day, 12-hour clock (01 to 12).
#!/usr/bin/ruby -w
time = Time.new
timeSwitch = 1
if (timeSwitch == 1)
puts time.strftime("%H:%M")
else
puts time.strftime("%I:%M")
end
Sorry about that had perl and ruby mixed up on syntax