I\'m working with Zend Framework 1.12 and Mysql. I want to add column in database, which save currenct datetime when record was inserted into table.
Anyone knows how can
There are different ways to do so.
You can define data type TIMESTAMP
and set default value to CURRENT_TIMESTAMP
You can define column with data type datetime
and use now()
or sysdate()
to get current date and time.
For eg.
INSERT INTO `table_name`(current_time) VALUES(now());
or
INSERT INTO `table_name`(current_time) VALUES(sysdate());
You can just define the column like:
DATETIME DEFAULT CURRENT_TIMESTAMP
you must change column type to TIMESTAMP , and in default field set CURRENT_TIMESTAMP