Limiting datetime_select to a certain start time

647 Views Asked by At

Is there a way to limit datetime_select in rails so that it only shows certain hours, e.g. so that the only options are 5pm-10pm? currently only have this:`

<%= f.label :time %><br>
<%= f.datetime_select :time,  :minute_step => 30 %>`
1

There are 1 best solutions below

1
On

This will give you an hour range between 5pm - 10pm

<%= f.datetime_select :time,  minute_step: 30, start_hour: 17, end_hour: 22 %>`