Click to See Complete Forum and Search --> : Storing Unix timestamp.


pcthug
10-13-2006, 07:13 AM
Hi, what would be the best method of storing a PHP generated Unix timestamp (from time() (http://au.php.net/manual/en/function.time.php))?
Thanks guys.

chazzy
10-13-2006, 01:06 PM
well, what is the purpose? if the only purpose is to store the time of insertion, then it's better to let mysql use it's NOW() function and store the data in a datetime column, then on select format it as you want.

NogDog
10-13-2006, 04:29 PM
If you do want to store the UNIX timestamp, store it as "INT UNSIGNED".

pcthug
10-13-2006, 10:57 PM
Ok, so I have chose to use the SQL NOW() function and it stores time in the following format YYYY-MM-DD HH:MM:SS. OK, that's fine, however on retrieval of this data is there a way of converting that into seconds only format via SQL or is it best handled with the PHP gmmktime() function?

NogDog
10-14-2006, 01:12 AM
If using MySQL, you can use the UNIX_TIMESTAMP() function in your query.