I am working on a project where I will have to store stats (how many times a website is visited etc.). I will have to manipulate the data by day, month, year. As in: select the last 7 days / select last month etc. I was wondering if I should go with timestamp (INT) or datetime.
i prefer datetime, because you can actually understand it when looking at the data, e.g. when using the dreaded, evil “select star” during preliminary testing
It seems fairly easy to me to create unixdate with php using time(). I have no idea how to record a date in the datetime format. Is it done with php? Through a mysql query?
Just out of curiosity, and so I can make my mind, before I dive into this, how would a query grabbing the 7 days prior to today look like with datetime? Would it be a lot different with a timestamp?
Keep in mind that MySQL has advanced a lot since this article was written but the article does point out some other factors that might influence what you use.
So, how should I enter a new datetime? Using NOW()?
Is datetime going to be harder to manoeuver than date? I’m thinking, why not store hours and seconds, I may need them in the future (but not right now).