Rails: Get the time from a datetime

Viewed 48614

If I have a datetime value of something like 1/10/2011 9:00:00, how do I get the 9:00 am from that datetime?

7 Answers

I needed 24 hour time e.g. 11pm would return "23" (not 11)

Time.current.strftime("%H")
=> "18"
Related