I am working on a project which needs to insert the member birthday’s into MySQL database. But i am confused. Actually i am using it like that:
int(10)
So i change the format e.g. “27/06/1960” to unix time using PHP and use the function date() to show the birthday. Is there any better solution? and is there any good resource you recommend to read about “DATE, DATETIME, TIMESTAMP”?
Thanks.
The fastest way to find out when somebody birthday is would be to use 2 or 3 separate INT columns and probably an addition column to store the whole thing as a DATETIME. While you don’t normally use ints nor multiple columns to represent date, keep in mind if you have a lot of rows in this table, doing something like
is not very efficient. It works fine in smaller datasets but become slow if we start getting into large datasets (depends on your hardware). Sometimes you need to store data in unusual ways to keep your system efficient, the tiny amount of HD space you waste by having up to 4 sets of date columns (month, day, year, and store the whole thing as a datestamp) pays off in speed.
By doing this you can simply do: