I noticed that the user table and the session table in drupal , the field for date is save in int(11). I wonder if why is it so, and why isn’t the date save in the mysql timestamp format. I am not doubting the work of the drupal community as I believe they may have a good reason to do this. But what happen when we want to sort the data in the database according to the date. If we saved it as int for varchar, we wouldn’t be able to sort it, unless we retrieve it out from the database and convert it back to the date format.
If anyone is curious how we convert it back from the integer to a readable date, most probably for reporting, this is how we do it :
echo date(’d/m/y’, ‘the date int’);
Â



Home