FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Number or date/time field for timestamp?





kv
In several topics about date/time formatting, several users have suggested to use a number field in mysql to store the date. I normally use date/time fields. Is there any specific advantage to use number field? Also what are the drawbacks? (One I can think of is, if it is number, it has to be converted to date/time format string to display and convert date/time string to number to store).
rvec
the only format which would be better when used in an int field would be the unix timestamp (not the mysql one). That's also easily used with PHP so that would be an advantage. Most of the PHP time and date functions take this as an input.

All mysql supported formats should be used with the right mysql data-type. In such cases it's never a good thing to use the int data type. You'd just ignore all the date functions mysql has.

Things like NOW() and comparing dates are only possible when using the mysql date data types.
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.