See Should I use the 'datetime' or 'timestamp' field? It has comprehensive coverage of the topic.
EDIT - Just to summarize the properties for MySQL and my experience with it -
Timestamp -
a) 4 bytes per column (compared to 8 for date and time)
- LOWER RANGE ('1970-01-01 00:00:01' UTC to '2038-01-09 03:14:07' UTC) THAN DATETIME - So definitely not use it for birth dates, etc. templates should actually provide a "timestamp" for "NOW" for actions such as updating strings, etc. etc.
b) stored internally as a whole
- Performance is wise ... my personal experience was mixed .. sometimes its faster ... sometimes slower than DATETIME. It takes up less space though.
c) Has time zone information!
- so - if I add '2011-01-01 3:30' to TIMESTAMP (with time zone in hours like EST - Boston). Later, I change the mysql server and timezone to PST (california) and reboot the server - the value will change to "2011-01-01 00:00" - (PLEASE CONFIRM ... I have experienced this for a long time). However, DATETIME will remain the same.
d) All DATE () / DAY () / MONTH () functions work for both TIMESTAMP and DATETIME
e) In MySQL, you can have multiple TIMESTAMPS for a table
- (YES, however, only one of them (the first) will be automatically updated with the time the line was updated, also ... only one can be made NOT NULL (I think the first))
f) the first TIMESTAMP in the table is automatically updated ...
- So be careful if you use it for other purposes .. and want to allow null there. (null is stored as "0000-00-00 00:00:00" in both DATETIME and TIMESTAMP)
I used several timestamps for other purposes. The necessary space has been saved (must be very careful and take into account all these problems.
My advice, go to TIMESTAMP for timeless purposes only if you know what you are doing .. and if SPACE is a huge concern (my eg are 15,000,000 rows and grow and 8 datetimes!))
Jai May 13 '11 at 9:06 a.m. 2011-05-13 09:06
source share