Rails. How to store time of day (for schedule)?

前端 未结 8 749
被撕碎了的回忆
被撕碎了的回忆 2020-12-13 02:25

I\'m writing an app that keeps track of school classes.

I need to store the schedule. For example: Monday-Friday from 8:am-11am.

I was think

8条回答
  •  攒了一身酷
    2020-12-13 02:43

    From the SQLite 3 website,

    "SQLite does not have a storage class set aside for storing dates and/or times. Instead, the built-in Date And Time Functions of SQLite are capable of storing dates and times as TEXT, REAL, or INTEGER values:

    TEXT as ISO8601 strings ("YYYY-MM-DD HH:MM:SS.SSS"). REAL as Julian day numbers, the number of days since noon in Greenwich on November 24, 4714 B.C. according to the proleptic Gregorian calendar. INTEGER as Unix Time, the number of seconds since 1970-01-01 00:00:00 UTC. Applications can chose to store dates and times in any of these formats and freely convert between formats using the built-in date and time functions."

    You can then manipulate the values using the Date and Time functions outlined here.

提交回复
热议问题