Timestamp vs. Datetime , which is better and what to use?

I’d personally go with timestamp all the time, for its accuracy, power, functions and the automatic timezone conversion by MySQL when entering and reading its value. Everything server time. Datetime stores only the ‘date’ value, much like 1st January 2014 , which very much has no function or meaning but behave like TEXT, a statement.


How to convert MySQL time to UNIX timestamp using PHP?

$timestamp = strtotime($mysqltime); (where $mysqltime is the timestamp data read from mysql)
echo date("Y-m-d H:i:s", $timestamp); (then use this to display nicely in date format)

when reading from datebase .. and formatting to show .. either use $timestamp  == UNIX_TIMESTAMP(datetime) , then in PHP.. date(‘Y-m-d H:i:s T’,$timestamp) *OR* use in PHP, $timestamp = strtotime(datetime) before date(‘Y-m-d H:i:s T’,$timestamp). Remember to compare with database value with the above date() format for accuracy.


the first timestamp field in a table, is automatically updated on a record change!

Something to consider though, DATETIME can store dates from 1000 AD to 9999 AD, while Timestamp, 1970 AD to 2038 AD only:

The DATETIME type is used when you need values that contain both date and time information. MySQL retrieves and displays DATETIME values in ‘YYYY-MM-DD HH:MM:SS’ format. The supported range is ‘1000-01-01 00:00:00’ to ‘9999-12-31 23:59:59’.

The TIMESTAMP data type has a range of ‘1970-01-01 00:00:01’ UTC to ‘2038-01-09 03:14:07’ UTC. It has varying properties, depending on the MySQL version and the SQL mode the server is running in.



facebooktwittergoogle plus


Website: Username limit from 15 to 60.

Hacked /templates/default/register.htm and changed maxlength=”15″ to maxlength=”60″

Hacked /uc_client/model/user.php – $len > 15 to $len > 60.


in common.inc.php
I changed this line: $_DCOOKIE[‘loginuser’] = !empty($_DCOOKIE[‘loginuser’]) ? substr(htmlspecialchars($_DCOOKIE[‘loginuser’]), 0, 15) : ”;

to $_DCOOKIE[‘loginuser’] = !empty($_DCOOKIE[‘loginuser’]) ? substr(htmlspecialchars($_DCOOKIE[‘loginuser’]), 0, 60) : ”;

facebooktwittergoogle plus


Website Fix: Chrome login from Forum problem.

Apparently, Chrome would not redirect after login. This seems to be an issue with common.js in Discuz 7.2

Had to hack Discuz 7.2 common.js to fix login problems on Chrome.


Had to change:

if(BROWSER.ie) { s = $(ajaxframeid).contentWindow.document.XMLDocument.text; } else { s = $(ajaxframeid).contentWindow.document.documentElement.firstChild.wholeText; }




if(BROWSER.ie) { s = $(ajaxframeid).contentWindow.document.XMLDocument.text; } else if (BROWSER.chrome > ‘0’) { s = $(ajaxframeid).contentWindow.document.firstChild.textContent; } else { s = $(ajaxframeid).contentWindow.document.documentElement.firstChild.wholeText; }

facebooktwittergoogle plus