How do I convert \"11am\" and \"10pm\" into \"11:00\" and \"22:00\"? Is there a simple way using the date and time classes?
Your question is unclear, but it sounds like you have a string "10pm", and you need to (1) capture it as a Time, and (2) represent that Time in 24-hour format. I would do it like this. First, gem install chronic
, then, write a script like this:
require 'chronic'
t = Chronic.parse('10pm')
p t.strftime("%H:%M")
Returns "22:00"