0

I have a DB field of type time The field stores just the time in the DB. When the field value is read with ActiveRecord in Rails 4.2 I get a dateTime value instead. Eg.:

08:30:00 in the database becomes 2000-01-01 08:30:00

Is this the expected behavior with AR?

Leo Net
  • 777
  • 6
  • 15

2 Answers2

-1

The database always stores these values. You can modify it though by using time.to_s(:db).

look at this answer

Community
  • 1
  • 1
Dylan L.
  • 1,243
  • 2
  • 16
  • 35
-1

There is no data format in MySQL which will save just the Time: it must have a date attached in order to be useful.

If you plan to get on the HH:MM:SS format,

please use rails function such as strftime("HH:MM:SS")...

additional info like: *to_time *to_date

aldrien.h
  • 3,437
  • 2
  • 30
  • 52