[development] no date / time types in schema API
karen at elderweb.com
Wed Jul 2 12:47:50 UTC 2008
>> A solution based on timestamps is much more elegant: timestamps need
>> no (database-specific) parsing whatsoever (both on reading and
>> writing to the database), they play nice with arithmetic (and thus
>You obviously have never dealt with timestamps for dates...
>They are a most royal PITA, especially when dealing with timezones and
Couldn't have said it better myself. The two people on this list who have probably spent more time than anyone else in Drupal trying to do things like proper timezone conversions on timestamps are in complete agreement that timestamps are a PITA.
They also don't work at all well for historical dates, nor for incomplete dates -- years and months with unspecified days or dates without times. They imply a level of precision to the second when that may not be at all true. They have no knowledge of timezones nor any way of dealing with timezones.
When you store a date in a database's native datetime format, the database can do timezone adjustments on the value, format the date values, and extract things like a month or year out of the date. If you store the date in a timestamp and need to do any of those things, you first have to come back and cast the timestamp as a datetime field, which is neither simple nor elegant, and works differently (and sometimes badly) in different databases.
Dates are complicated beasts. Treating them as timestamps doesn't solve the problems, it just creates different ones.
I'm looking forward to getting them out of Drupal core.
More information about the development