3 Comments Already

commenter
Dimas Said,
July 13th, 2009 @3:52 pm  

My initial thinking was along the same lines as yours: having a single timestamp value and the others as datetime. My thinking has since changed to having all datetime values as TIMESTAMP fields because: depending on your development environments it will not always be guaranteed that the timezone values set for deployment servers will be similar, equally the changing of timezone values can screw up the datetime inputs into your tables.

Saving as DATETIME means that you are saving the datetime value in the current operating timezone.

Saving as TIMESTAMP means that MySQL will convert the datetime from the operating timezone into UTC (Unix Time) and store it, then convert it back to the operating timezone on retrieval. Using TIMESTAMP fields makes avoids confusion and allows you to accurately display with out the worrying which timezone the datetime is stored as in the database.

Current score: 0
commenter
FroDo Said,
August 4th, 2009 @4:03 am  

@Diamas: You are perfectly right – I think the fact that the data in a timestamp row is stored in UTC is a even more more important feature of this data type than the auto update function!

Current score: 0
commenter
August 12th, 2009 @9:45 am  

“Note that only one of the fields can be TIMESTAMP, that’s a limitation of MySQL.”

This is not true. You can have as many TIMESTAMP columns as you like in a table. The only limitation is that the first TIMESTAMP column in the table is updated when the record is updated and the other TIMESTAMP columns are not.

Current score: 0

Related Post

Please Leave Your Comments Below

Please Note: All comments will be moderated