I've always just kind of randomly chosen DATETIME or TIMESTAMP. What are the pros/cons of each and what do you use and why? (I realize some have more detail, I'm usually looking for year/month/day/hour/minute/second resolution and I'm currently working with PHP, AS3, and Objective-C.
preguntado el 09 de enero de 11 a las 09:01
Timestamp can be updated/created automatically and can reflect on changing the timezone mysql session variable. Also
date can store the dates of wider range (2038 vs 9999).
As for me - I prefer to use timestamp everywhere, since it is easy to display the time in user's timezone.
Where $tz is an offset in format
+10:00 or string timezone representation like
Asia/Vladivostok. After you perform this query - all the dates will be automatically converted to expected timezone. And from another point of view - each date you're storing in database will be stored with a glance of current timezone. (
timestamp is stored in UTC, and mysql just offsets it when returns data to you, according the