TeddyKiller Posted March 25, 2010 Share Posted March 25, 2010 What you reckon? what is best, 00:00:00 DD MM YY format, or Timestamp. Thanks Link to comment https://forums.phpfreaks.com/topic/196539-date-what-is-best-000000-dd-mm-yy-or-timestamp/ Share on other sites More sharing options...
Mchl Posted March 25, 2010 Share Posted March 25, 2010 For what? Link to comment https://forums.phpfreaks.com/topic/196539-date-what-is-best-000000-dd-mm-yy-or-timestamp/#findComment-1031888 Share on other sites More sharing options...
premiso Posted March 25, 2010 Share Posted March 25, 2010 I prefer to go with this: YYYY-MM-DD HH:MM:SS As two digit years can be easily confused with months and or confused with milleniums. Timestamps I do not care for as they have a limit of something like 1969 - 2032. So they do not work for birthdates and other historical / furturistic dates. Link to comment https://forums.phpfreaks.com/topic/196539-date-what-is-best-000000-dd-mm-yy-or-timestamp/#findComment-1031890 Share on other sites More sharing options...
TeddyKiller Posted March 25, 2010 Author Share Posted March 25, 2010 Ah.. yeah I was thinking timestamps for everything in the database, people DOB, last login etc. Though if theres a limit then.. wouldn't be that great to use for DOB atleast. Link to comment https://forums.phpfreaks.com/topic/196539-date-what-is-best-000000-dd-mm-yy-or-timestamp/#findComment-1031895 Share on other sites More sharing options...
Mchl Posted March 25, 2010 Share Posted March 25, 2010 It's pretty much useless for DOBs or other historic events. It works pretty well for... well timestamping (i.e. recording when events in your application happen). Remember that MySQL's DATETIME takes 8 bytes, while TIMESTAMP is only 4 bytes. DATE however is only 3 bytes (that's for MyISAM, but I suspect it's quite similar for InnoDB) http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html Link to comment https://forums.phpfreaks.com/topic/196539-date-what-is-best-000000-dd-mm-yy-or-timestamp/#findComment-1031900 Share on other sites More sharing options...
salathe Posted March 25, 2010 Share Posted March 25, 2010 I'm going to play devil's advocate and vote for the Unix timestamp, at least that value is constant(ly incrementing) whereas a formatted string like the one in the OP leaves plenty of room for errors: of the timezone variety, and lack of range (YY). Link to comment https://forums.phpfreaks.com/topic/196539-date-what-is-best-000000-dd-mm-yy-or-timestamp/#findComment-1031904 Share on other sites More sharing options...
Mchl Posted March 25, 2010 Share Posted March 25, 2010 I'm going to play devil's advocate and vote for the Unix timestamp, at least that value is constant(ly incrementing) whereas a formatted string like the one in the OP leaves plenty of room for errors: of the timezone variety, and lack of range (YY). That's why it (UNIX time)'s so good for timestamping Link to comment https://forums.phpfreaks.com/topic/196539-date-what-is-best-000000-dd-mm-yy-or-timestamp/#findComment-1031912 Share on other sites More sharing options...
jmajeremy Posted March 25, 2010 Share Posted March 25, 2010 premiso and salathe both have good ideas. I tend to use the YYYY-MM-DD HH:MM:SS format for compatibility with MySQL, but it could also be a good idea to take note of the UNIX timestamp as a backup, or unique identifier. On a high-traffic website it's possible to have more than one transaction occur within the same second, but it's unlikely you'll ever get two identical UNIX timestamps. Link to comment https://forums.phpfreaks.com/topic/196539-date-what-is-best-000000-dd-mm-yy-or-timestamp/#findComment-1031913 Share on other sites More sharing options...
Mchl Posted March 25, 2010 Share Posted March 25, 2010 On a high-traffic website it's possible to have more than one transaction occur within the same second, but it's unlikely you'll ever get two identical UNIX timestamps. Actually, if transactions happen within one second there is a very high probability they'll get same timestamp. After all it's number of SECONDS since Epoch. Link to comment https://forums.phpfreaks.com/topic/196539-date-what-is-best-000000-dd-mm-yy-or-timestamp/#findComment-1031924 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.