Rails Time Column Not Respecting Minutes
I have a Time column on one of my models in Rails 6. I'm having an issue with the time I have saved in the database not matching the result of strftime. Here is my byebug output:
(byebug) record.end
Fri, 31 Dec 1999 18:00:00 CST -06:00
(byebug) record.end.strftime("%I:%m %P")
"06:12 pm"
As you'll see, the minutes aren't respected unless I call strftime. How can I fix this? I want the minutes to be calculated in record.end so that I can use the column for calculations. Currently, everything is 12 minutes off.
Here is the migration I made to make this a Time column. The column was initially a DateTime.
class ChangeStartAndEndColumnTypesOnTimeRecord < ActiveRecord::Migration[6.0]
def change
change_column :time_records, :start, :time
change_column :time_records, :end, :time
end
end
from Recent Questions - Stack Overflow https://ift.tt/32NgzG9
https://ift.tt/eA8V8J
Comments
Post a Comment