phpmady Posted September 28, 2010 Share Posted September 28, 2010 Hi, I am writing a advertisement system, where i have two fields Ad_Start_date Ad_End_Date i was always confused, in doing this things regarding date whether to use datetime or timestamp in mysql Thanks, Quote Link to comment https://forums.phpfreaks.com/topic/214631-what-will-be-the-best-way-to-store-date/ Share on other sites More sharing options...
litebearer Posted September 28, 2010 Share Posted September 28, 2010 my personal preference datetime Quote Link to comment https://forums.phpfreaks.com/topic/214631-what-will-be-the-best-way-to-store-date/#findComment-1116802 Share on other sites More sharing options...
Pikachu2000 Posted September 28, 2010 Share Posted September 28, 2010 Ditto on the DATETIME. Quote Link to comment https://forums.phpfreaks.com/topic/214631-what-will-be-the-best-way-to-store-date/#findComment-1116803 Share on other sites More sharing options...
ignace Posted September 28, 2010 Share Posted September 28, 2010 Your choices should be based on knowledge/information not preference! If your row contains ONE timestamp it will update this one on each UPDATE regardless if you specified a value for it, the same applies for the first TIMESTAMP column if you have multiple such fields. Quote Link to comment https://forums.phpfreaks.com/topic/214631-what-will-be-the-best-way-to-store-date/#findComment-1116816 Share on other sites More sharing options...
AbraCadaver Posted September 28, 2010 Share Posted September 28, 2010 Your choices should be based on knowledge/information not preference! If your row contains ONE timestamp it will update this one on each UPDATE regardless if you specified a value for it, the same applies for the first TIMESTAMP column if you have multiple such fields. This is partially true. You can control this with DEFAULT and ON UPDATE. This automation is a feature of TIMESTAMP if you want to use it. The major difference is DATETIME is 1000-01-01 00:00:00' to '9999-12-31 23:59:59' whereas TIMESTAMP is only '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07. Quote Link to comment https://forums.phpfreaks.com/topic/214631-what-will-be-the-best-way-to-store-date/#findComment-1116841 Share on other sites More sharing options...
unknowncat Posted September 28, 2010 Share Posted September 28, 2010 I use the date() function a lot. Easy to work with the raw number. Make a db input of 15 int, then set the date/time with Linux Timestamp. Set something like $now = date(); then use $now in the sql insert. This way all db times are set at that standard, and whenever retrieving that data, you can manipulate or use that in whatever way you want. Really helps for finding the difference between two times, and can be presented however you want using something like date("F j, Y", $dateEarned); Quote Link to comment https://forums.phpfreaks.com/topic/214631-what-will-be-the-best-way-to-store-date/#findComment-1116916 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.