In Ruby on Rails, what's the difference between DateTime, Timestamp, Time and Date?

后端 未结 3 582
情歌与酒
情歌与酒 2020-11-28 17:19

In my experience, getting dates/times right when programming is always fraught with danger and difficulity.

Ruby and Rails have always eluded me on this one, if onl

3条回答
  •  情话喂你
    2020-11-28 17:52

    1. :datetime (8 bytes)

      • Stores Date and Time formatted YYYY-MM-DD HH:MM:SS
      • Useful for columns like birth_date
    2. :timestamp (4 bytes)

      • Stores number of seconds since 1970-01-01
      • Useful for columns like updated_at, created_at
    3. :date (3 bytes)
      • Stores Date
    4. :time (3 bytes)
      • Stores Time

提交回复
热议问题