Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Date storage format
January 1, 2008, 2:22 pm
rate this thread
I'm trying to teach myself some PHP and MySQL and the project that I've
decided to build will be dependent on queries involving comparisons of
dates. I'd like some advice, please, on whether I should -
1. Store the date (2008-01-01) in the MySQL table as a date and compare to
2. Create a/ timestamp/s for the date/s in question, store the timestamp and
then compare to that.
If the timestamp is the way to go, should that column be of type "Timestamp"
or will that cause the string to be altered to a MySQL timestamp?
Thank you in advance for any assistance.
Re: Date storage format
The same to you.
If you plan to base a lot of queries on date lookups/comparisons, go for
the native date format in MySQL. Any formatting of a date-output can be
done with MySQL itself. Should you need a timestamp for some reason in the
PHP code itself (be very sure you need this... MySQL might be more capable
then you think), you can always query the timestamp using UNIX_TIMESTAMP()
on the column.