Auto TimeStamp new entry to DB (phpMyAdmin)

前端 未结 2 712
悲&欢浪女
悲&欢浪女 2020-12-30 00:09

If I want each new entry into my db to be automatically timestamped, would I set the Field Type to \"timestamp\" and have the Default value set to \"CURRENT_TIMESTAMP\"?

2条回答
  •  生来不讨喜
    2020-12-30 00:29

    That is correct. In SQL code that would be:

    CREATE TABLE `table` (
        ...
        `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, 
        ...
    )
    

提交回复
热议问题