mardi 31 juillet 2018

time format using helper method in ruby on rails

I have time data filed in my table

t.time "start_time"
t.time "end_time"

and when I add the data it displays in this format

Start Time  2000-01-01 06:00:00 UTC
End Time    2000-01-01 08:00:00 UTC

I want only time to be displayed? How do I do that.?

my form is like this

      <div class="form-group row">
         <%= form.label :start_date, class: "control-label text-right col-md-2" %>
         <div class="col-md-4">
           <div class="input-group">
             <%= form.text_field :start_date, id: :course_start_date, value: "#{format_date(form.object.start_date)}", class: "form-control mydatepicker" %>
             <span class="input-group-addon"><i class="icon-calender"></i></span>
         </div>
        </div>
      </div>
      <div class="form-group row">
         <%= form.label :end_date, class: "control-label text-right col-md-2" %>
         <div class="col-md-4">
           <div class="input-group">
              <%= form.text_field :end_date, id: :course_end_date, value: "#{format_date(form.object.end_date)}", class:"form-control mydatepicker" %>
              <span class="input-group-addon"><i class="icon-calender"></i></span>
           </div>
         </div>
      </div>

Aucun commentaire:

Enregistrer un commentaire