I’m creating a 24 hour dropdown with 30 minute increments for a set time when someone wants to arrive at a destination and was wondering is there a good format to use and how do you convert it to type Time (since I am storing it in the database as a Time type).
These are the options I am using:
def options_for_hours_select
[
['4 AM','4'],
['4:30 AM','430'],
#etc
]
end
If you are using 30 minute increments, you could change use numeric option values, like this:
then, when you want to convert it to a time, you can just add that many hours to the start of the day, (ActiveSupport makes this particularly easy) e.g.:
and if you have two parameters
:dateand:arrival_time, you could combine them like this: