prudens Posted May 30, 2008 Share Posted May 30, 2008 Hi, I am trying to create a mySQL that stores "DATE_SIGNUP", "DATE_TERM1", "DATE_TERM2" I want to store something like: "DATE_SIGNUP": 2008-05-05 "DATE_TERM1": 2008-05-01 "DATE_TERM2": 2010-05-10 What kind of mySQL type would be good for those data? Also, how do I determine the timezone of the user? Would "DATE" datatype store timezone information of the user? Link to comment https://forums.phpfreaks.com/topic/107923-hmm-what-should-i-use/ Share on other sites More sharing options...
AndyB Posted May 30, 2008 Share Posted May 30, 2008 The only rational field type for storing dates is DATE. Your field names would be date_signup, etc., etc. (just in case you were considering concatenating date_signup and the date). A good method of keeping the date simple is to use gmdate(), i.e. all dates are GMT so you can do comparisons without regard to the user's actual TZ. TZ is best obtained from the user via a dropdown select in the data input form. Link to comment https://forums.phpfreaks.com/topic/107923-hmm-what-should-i-use/#findComment-553221 Share on other sites More sharing options...
prudens Posted May 30, 2008 Author Share Posted May 30, 2008 what if I don't want the date, just Month and Year? 2008-05. Can I store just 2008-05 in DATE format? Link to comment https://forums.phpfreaks.com/topic/107923-hmm-what-should-i-use/#findComment-553233 Share on other sites More sharing options...
AndyB Posted May 30, 2008 Share Posted May 30, 2008 what if I don't want the date, just Month and Year? 2008-05. Can I store just 2008-05 in DATE format? No. DATE is specific yyyy-mm-dd. But if you only want year and month (despite your original post) who cares that the day is also stored. Store the date, use whatever you need of it. Link to comment https://forums.phpfreaks.com/topic/107923-hmm-what-should-i-use/#findComment-553240 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.