ademcan / canSnippet

An open source web-based snippets management tool
MIT License
48 stars 7 forks source link

Fix the format used to store the date #26

Closed zertrin closed 10 years ago

zertrin commented 10 years ago

Store the date as ISO 8601 YYYY-MM-DD HH:MM:SS string

There is no true DATE type in SQLite (http://www.sqlite.org/datatype3.html)

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.

I think ISO8601 strings are in our case a good balance between readability and usefulness.

bawaaaaah commented 10 years ago

why you don't use timestamp for storing and use date function in php to convert it to iso 8601 date

zertrin commented 10 years ago

Well it doesn't bring a lot, you can already convert from ISO 8601 to timestamp or anything directly in the database. (see http://www.sqlite.org/lang_datefunc.html). The ISO8601 string keeps it simple, yet flexible.

bawaaaaah commented 10 years ago

ok

ademcan commented 10 years ago

Thank you for the commit and the details :)