{"id":53,"date":"2021-01-12T09:22:05","date_gmt":"2021-01-12T09:22:05","guid":{"rendered":"https:\/\/veltzer.net:8890\/?p=53"},"modified":"2021-01-12T09:22:05","modified_gmt":"2021-01-12T09:22:05","slug":"producing-mysql-dates-from-perl","status":"publish","type":"post","link":"https:\/\/veltzer.net:8890\/producing-mysql-dates-from-perl\/","title":{"rendered":"Producing MySQL dates from Perl"},"content":{"rendered":"\n
Ever written the occasional Perl script and wanted to insert the current date and time into a MySQL database? Here is the function to do it. This works for a column of type \u2018datetime\u2019.<\/p>\n\n\n\n
# function to return the current time in mysql format\nsub mysql_now() {\n my($sec,$min,$hour,$mday,$mon,$year,$wday, $yday,$isdst)=localtime(time);\n my($result)=sprintf(\"%4d-%02d-%02d %02d:%02d:%02d\",$year+1900,$mon+1,$mday,$hour,$min,$sec);\n return $result;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"Ever written the occasional Perl script and wanted to insert the current date and time into a MySQL database? Here is the function to do it. This works for a column of type \u2018datetime\u2019.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[10],"tags":[67,68,65,64,8,23,66],"_links":{"self":[{"href":"https:\/\/veltzer.net:8890\/wp-json\/wp\/v2\/posts\/53"}],"collection":[{"href":"https:\/\/veltzer.net:8890\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/veltzer.net:8890\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/veltzer.net:8890\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/veltzer.net:8890\/wp-json\/wp\/v2\/comments?post=53"}],"version-history":[{"count":1,"href":"https:\/\/veltzer.net:8890\/wp-json\/wp\/v2\/posts\/53\/revisions"}],"predecessor-version":[{"id":54,"href":"https:\/\/veltzer.net:8890\/wp-json\/wp\/v2\/posts\/53\/revisions\/54"}],"wp:attachment":[{"href":"https:\/\/veltzer.net:8890\/wp-json\/wp\/v2\/media?parent=53"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/veltzer.net:8890\/wp-json\/wp\/v2\/categories?post=53"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/veltzer.net:8890\/wp-json\/wp\/v2\/tags?post=53"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}