How to set default value of a mysql column as unix_timestamp?
mysql, unix-timestamp
Solution
Note : I have no idea about the performance of MYSQL TRIGGER
Please go through these links
Identify some of the drawback of implementing sql server triggers
Using Triggers
You can create triggers for this.
for insertion
`CREATE TRIGGER {trigger_name} BEFORE INSERT ON {table_name} FOR EACH ROW SET new.{field_name} = UNIX_TIMESTAMP(NOW()); `
for update
`CREATE TRIGGER {trigger_name} BEFORE UPDATE ON {table_name} FOR EACH ROW SET new.{field_name} = UNIX_TIMESTAMP(NOW());`
Problem
I was thinking at something like this: ``` `post_modified` int(11) NOT NULL DEFAULT UNIX_TIMESTAMP (NOW ()) ON UPDATE UNIX_TIMESTAMP (NOW ()), ``` But this code it is not working.