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


MySQL dates





jmraker
I always store date & time in a database as a timestamp as it's easiest to work with and it seems to work ok. I was wondering if there was a good reason enough reason to start storing the date & time in mysql's date format.

I'm guessing pro mysql DATETIME is
    . There's no year 2038+ timestamp bug on my mysql side, but if php handles dates after 2038 it wouldn't be much of an advantage
    . Human readable outside of programs and for looking over logged sql statements
    . You can just use UNIX_TIMESTAMP() and FROM_UNIXTIME() in sql statements to get/set the date, or have php do the extra step and parse the field into a timestamp
    . If you use another programming language that does timestamps differently

What format do you like to store date & time in and why?
Peterssidan
I also store it as a unix timestamp. I think it's a very simple format that is easy to understand, and standard. I don't think the 2038 timestamp bug is much to worry about. All new computers will probably be 64 bit at that point so we only have to remember to make the MySQL datatype big enough.

I have never used DATETIME so I am not aware of the potentially benefits. I guess it's more human readable, which might attract some people.
badai
i always use datetime because of "human readable" factor, and i can edit it directly using mysql client like phpmyadmin or navicat. php is also smart enough that it can directly manipulate yyyy-mm-dd format.

but in oracle, i just have to resort to timestamp because it's too stupid to recognize date string and have to use to_date function everytime.

i also notice veteran coder always use timestamp. maybe because when they start working, there is no datetime data type.
Related topics
a grouping question?
mysql is allowed to connect from out of frihost host
Logic MySql
mysql connection question
php admin and mysql admin console
Mysql And PHP HELP PLZ
Question about MySQL!
Do you use a CMS script?
PHP, MySQL...
PHP Book (Php and Mysql for Dynamic Web Sites)
few mysql questions
E-Cards with PHP & MySQL
HTTP AUTH with PHP and mySQL
Build an online dictionary by PHP/MySQL
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.