开发者

How to store current time in database

I want have a field in mysql where the Current time must be auto-ge开发者_运维百科nerated, say when the record is inserted into it.

Please help me ........


From MySQL:

In a CREATE TABLE statement, the first TIMESTAMP column can be declared in any of the following ways:

With both DEFAULT CURRENT_TIMESTAMP and ON UPDATE

CURRENT_TIMESTAMP clauses, the column has the current timestamp for its default value, and is automatically updated.


You could have a TIMESTAMP field, with the default set to CURRENT TIMESTAMP.

You can also use the ON UPDATE CURRENT TIMESTAMP property and it will change whenever any field on the row is updated.

http://dev.mysql.com/doc/refman/5.0/en/timestamp.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜