mysql timestamp default date code example
Example 1: mysql CURRENT_TIMESTAMP()
CURRENT_TIMESTAMP()
Example 2: mysql timestamp to date
-- Use the FROM_UNIXTIME() function in MySQL
select from_unixtime(timestamp) from my_tbl;
Example 3: mysql change timestamp on update
ALTER TABLE whatevertable
CHANGE whatevercolumn
whatevercolumn TIMESTAMP NOT NULL
DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP;
Example 4: mysql on update current_timestamp
Press CTRL+C to copy CREATE TABLE t1 (
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
dt DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);