{"id":139,"date":"2011-11-02T01:46:02","date_gmt":"2011-11-02T01:46:02","guid":{"rendered":"http:\/\/www.evermoredevnotes.com\/?p=139"},"modified":"2011-11-02T01:46:02","modified_gmt":"2011-11-02T01:46:02","slug":"mysql-triggers-for-inserted-and-updated-unix-timestamps","status":"publish","type":"post","link":"https:\/\/www.evermoretechnologies.com\/blog\/2011\/11\/mysql-triggers-for-inserted-and-updated-unix-timestamps\/","title":{"rendered":"MySQL triggers for inserted and updated unix timestamps"},"content":{"rendered":"<p>Here&#8217;s the sql I use when creating a database for an app where it&#8217;s assumed each table will have columns that store unix time stamps for their created date and time, and updated date and time. \u00a0It assumes that there is a column named created and one named updated on the table.<\/p>\n<p>[code]<br \/>\ncreate trigger {table}_set_timestamp_on_insert before insert on {table} for each row set new.created = unix_timestamp(now()), new.updated = unix_timestamp(now());<br \/>\ncreate trigger {table}_set_timestamp_on_update before update on {table} for each row set new.updated = unix_timestamp(now());<br \/>\n[\/code]<\/p>\n<p>Triggers are awesome like that.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s the sql I use when creating a database for an app where it&#8217;s assumed each table will have columns that store unix time stamps for their created date and&#8230; <a href=\"https:\/\/www.evermoretechnologies.com\/blog\/2011\/11\/mysql-triggers-for-inserted-and-updated-unix-timestamps\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7,10],"tags":[],"_links":{"self":[{"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/139"}],"collection":[{"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/comments?post=139"}],"version-history":[{"count":0,"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/139\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/media?parent=139"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/categories?post=139"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/tags?post=139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}