I’m using ‘$timestamp=time();’ function in php to set the current time.
Anyway – What should I use for this column’s definition in mysql? is it int? something else? and how much space?
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
MySQL does have a native DateTime type which you can use, or else you can store the unix timestamp as an INT. There are subtle differences between the two. If you want to do any date manipulation in your queries (such as retrieving all entries in the last week) then MySQL’s native column type is probably best. Either way you may need to think about how you handle timezones – even if you don’t think it’s relevant now it may well be further down the line (just handling DST for example). There is a whole book on handling dates and times in PHP (PHPArch book on Date and Time). I haven’t read it (yet!) myself but Derrick Rethans, the author, knows pretty much everything there is to know on the subject.