This is a really simple question, and it\'s probably been asked and answered before, but I haven\'t been able to find anything.
Anyway, I need a range/array for 12 hour
I agree with @MrYoshi's comment, the easiest way of formatting a date is .strftime()
,
see RubyDoc for all possible options
Example:
Time.now.strftime("%I:%M %p")
output: HH:MM AM
Or what you literally asked for:
Time.now.strftime("%I:00")
output: HH:00
As you mentioned time_select
I assume you want to offer time as a user selectable range, so try these options for time_select
(more options):
time_select 'game', 'game_time', {:minute_step => 60, :ampm => true}
also this previous question: Time select form helper with 12 hour format for Rails 3?