Jump to content

Hmm, what should I use??


prudens

Recommended Posts

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

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.