简体   繁体   中英

How can i set hour and minute in time select on 1 input field?

I want to set my time select like this click here

I used = course_form.input :start_at, label: false and html show hour select in 1 input field and minute in another input field.

check the datetime select api ..

starts_at is datetime field
##migration file
t.datetime :starts_at

Simple code snippet can be like this with multiple configurations:-

<div class="form_group">
   <label>Start time:</label></br>
      <%= f.datetime_select :starts_at , :class=>"form-control",:start_year => Date.current.year, :end_year => Date.current.year,:selected=> Date.today, :order=> [:day, :month, :year],:start_year=> Time.now.year,:default=> 1.days.from_now,:prompt=> {day: 'Choose day', month: 'Choose month', year: 'Choose year'},:placeholder=>"Enter start time",:required=>true %>
</div>

hope it helps

Maybe you should try to use one of the timepickers . https://www.sitepoint.com/10-jquery-time-picker-plugins/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM