i am using MYSQL database and would like to know which of this is a good practice.
way 1 - use column type in DB as timestamp. i.e will contain values like 2012-11-13 00:00:00 way 2 - use column as Date. i.e will contain values like 2012-11-13 in the database.
The question here is, to Store DOB. do we really need timestamp as the column type ? also the time section (00:00:00) is not required for a DOB in my opinion.
Should it be timestamp because, then we can store the value as hidden so no body can view it even when somebody see the DB. to view, we must use strtotime() available in php.
Please let me know the correct way to store DOB in database.
I recommend to use DATE.
TIMESTAMP has a range of '1970-01-01 00:00:01' to '2038-01-19 03:14:07' (UTC), so it doesn't fit for DOB in most cases.
It is possible to use DATETIME, but you should ask yourself: do you want users to fill in time of birth? If not - use DATE.
Usually it's not a big deal, but you may also consider required storage:
DATE: 3 bytes
TIMESTAMP: 4 bytes
DATETIME: 8 bytes
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments