I've this app in rails where one of the model has an attribute of time field, but after saving the form when I'm rendering the model data then I'm seeing a default date as well.
Here's the field-
<%= form.label :Time%>
<%= form.time_field(:timeOfservice, :class=>'form-control mb-2',
:min=>"10:00",
:max=>"20:00",
:step=>'3600',
required: true,
id: :appointment_timeOfservice,
:autocomplete=>'off') %>
This is what's showing on the page
2000-01-01 13:00:00 UTC
The time is being saved perfectly for each form of that model but the date 2000-01-01 with time is showing on every form of that model.
Can anyone explain how to correct this? I only want time to show not the date.
I think that's because Ruby and/or Rails doesn't have any data type to represent time of the day objects without the date component.
You will have to develop your own application logic to deal with the fact that the object that comes from ActiveRecord for that column is, indeed, a DateTime object (even if in the database is only stored the time of day component).
There is already a good answer for a similar question that you can check it out here: https://stackoverflow.com/a/34979912/1781212