How to: MySQL “created” column default value of NOW()
MySQL is gay in a lot of ways, but no more to me than the inability to use NOW() on a “created” column.
So here’s what you do — Create 2 columns both of the TIMESTAMP data type:
modified – on update CURRENT_TIMESTAMP
created – default value CURRENT_TIMESTAMP (instead of now) and you should be good!
You can’t use NOW() for some reason, MySQL hates it. Instead slap on that sand paper condom, bend MySQL over and use CURRENT_TIMESTAMP instead.
Hopefully sometime in 2015 the jackasses fix it so you can use custom functions as default values, but until then, this will have to do.
