How do I convert "11am" and "10pm" into "11:00" and "22:00"? Is there a simple way using the date and time classes?
The Time class has no parse method, but DateTime has.
require 'date'
DateTime.parse("11pm").strftime("%H:%M") #=> "23:00"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With