Set the default time to the current value in MySQL

Mysql> create a table by adding this column and stating default values as follows:

CREATE TABLE `table1` (
  `id` int(11) NOT NULL,
  `createtime` timestamp NULL default CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

If you are operating under Navicat, set the field type to TIMESTAMP, and write CURRENT_TIMESTAMP as the default value, as shown below:

Add a new column to an existing table

ALTER TABLE table1
ADD COLUMN  `createtime` timestamp NULL DEFAULT CURRENT_TIMESTAMP

3. Modify the time format of a column and add the default value

alter table table1 
 change createtime newtime timestamp null default current_timestamp

Read More: