自动时间戳新条目到数据库 (phpMyAdmin)

2022-01-05 00:00:00 timestamp mysql phpmyadmin

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"?

Is this the correct method?

解决方案

That is correct. In SQL code that would be:

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

相关文章