Welcome Guest, Not a member yet? Register   Sign In
Database Timestamp ?

Hi guys

Quick question regarding database automatic timestamps.

From the User Guide ...


This boolean value determines whether the current date is automatically added to all inserts and updates. If true, will set the current time in the format specified by $dateFormat. This requires that the table have columns named ‘created_at’ and ‘updated_at’ in the appropriate data type.


This value works with $useTimestamps to ensure that the correct type of date value gets inserted into the database. By default, this creates DATETIME values, but valid options are: datetime, date, or int (a PHP timestamp).

Which do you use and why?

Does the datetime option use the MySql timestamp, or is this not used at all.



When it comes to timestamps you can either use it from the web server where PHP is installed or the database server (assuming that they are not installed on the same server). In most of my cases I've used a combination of both. It just depends on the system and sometimes the location of the web server and or database server.


Thanks for the reply.

I would really rather use the time from PHP, and was wondering which of the options above would be ruled out based on that decision, as I have no idea how the database model inserts or doesnt insert the timestamp fields.


Hi again.

Is my thinking correct on this.

The default is datetime, so my database columns will need to be VARCHAR(25).

If I choose INT, then my database columns will need to be INT(14).

If i,m using Mysql timestamps, then that's handled by the database, so I should not be using $useTimestamps = true.


No you use either TIMESTAMP or DATETIME for storing the date / time fields.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

Theme © iAndrew 2016 - Forum software by © MyBB