Convert 24 integer to 12 hour with am/pm
date, datetime, ruby, time
Solution
[14, 0, 23].map { |hour| Time.parse("#{hour}:00").strftime("%l %P") }
=> [" 2 pm", "12 am", "11 pm"]
Problem
I'm using ruby. I'm trying to figure out how to convert the following.. `14` becomes `2 pm` `0` becomes `12 am` `23` becomes `11 pm` Thanks!