{"id":1501,"date":"2017-04-18T22:18:00","date_gmt":"2017-04-18T14:18:00","guid":{"rendered":"http:\/\/coderbee.net\/?p=1501"},"modified":"2017-04-18T14:19:38","modified_gmt":"2017-04-18T06:19:38","slug":"mysql-datetime-%e4%b8%8e%e6%97%b6%e5%8c%ba","status":"publish","type":"post","link":"https:\/\/coderbee.net\/index.php\/db\/20170418\/1501","title":{"rendered":"MySQL datetime \u4e0e\u65f6\u533a"},"content":{"rendered":"<h2>\u95ee\u9898<\/h2>\n<p>\u6700\u8fd1\u78b0\u5230\u8fd9\u6837\u7684\u95ee\u9898\uff1ajdbc \u63d2\u5165 timestamp \u7c7b\u578b\u7684\u6570\u636e\u5230 MySQL \u7684 datetime \u7c7b\u578b\u5217\u65f6\uff0c\u5c0f\u65f6\u4f1a\u53d8\u6210 12 \u5c0f\u65f6\u5236\u4e86\u3002\u6bd4\u5982 2017-04-11 15:24:32 \u53d8\u6210 2017-04-11 03:24:32<\/p>\n<p>\u4e00\u5f00\u59cb\u4ee5\u4e3a\u662f\u9ed8\u8ba4\u65f6\u533a\u8bbe\u7f6e\u5bfc\u81f4\uff0c\u540e\u9762\u53d1\u73b0\u4e0d\u662f\uff0c\u5728 MySQL client \u547d\u4ee4\u884c\u91cc\u76f4\u63a5\u63d2\u5165\u662f\u4e0d\u5b58\u5728\u8fd9\u6837\u95ee\u9898\u7684\u3002<\/p>\n<p>\u5982\u679c\u662f\u65f6\u533a\u95ee\u9898\uff0c\u8ddf\u672c\u5730\u65f6\u95f4\u76f8\u5dee\u4e0d\u4f1a\u662f 12 \u5c0f\u65f6\u7684\u3002<\/p>\n<p>\u7ed5\u8fc7\u65b9\u6cd5\uff1a<br \/>\n1. \u76f4\u63a5\u4f7f\u7528 MySQL \u7684 <code>now()<\/code> \u51fd\u6570\uff1b<br \/>\n2. \u5728 Java \u91cc\u628a timestamp \u8f6c\u6362\u4e3a <code>yyyy-MM-dd HH:mm:ss<\/code> \u683c\u5f0f\u5b57\u7b26\u4e32\uff0c\u7136\u540e\u7528 MySQL \u7684 convert \u51fd\u6570\u8fdb\u884c\u8f6c\u6362\u3002<\/p>\n<h2>\u65f6\u533a<\/h2>\n<p>CET, Central European Time\uff0c\u6b27\u6d32\u4e2d\u90e8\u65f6\u95f4\uff1a\u6bd4\u4e16\u754c\u6807\u51c6\u65f6\u65e9\u4e00\u4e2a\u5c0f\u65f6\u3002\u51ac\u5b63\u65f6\u95f4\u4e3a UTC+1\uff0c\u590f\u5b63\u6b27\u6d32\u590f\u4ee4\u65f6\u4e3a UTC+2<\/p>\n<p>UTC, Coordinated Universal Time, \u4e16\u754c\u6807\u51c6\u65f6\u95f4\u6216\u4e16\u754c\u534f\u8c03\u65f6\u95f4\uff1a<\/p>\n<p>GMT, Greenwich Mean Time, \u683c\u6797\u5c3c\u6cbb\u6807\u51c6\u65f6\u95f4\u3002<\/p>\n<p>CST, China Standard Time, \u4e2d\u56fd\u6807\u51c6\u65f6\u95f4\u3002<\/p>\n<p>CST \u540c\u65f6\u53ef\u4ee5\u4ee3\u8868\u5982\u4e0b 4 \u4e2a\u4e0d\u540c\u7684\u65f6\u533a\uff1a<br \/>\nCentral Standard Time (USA) UT-6:00<br \/>\nCentral Standard Time (Australia) UT+9:30<br \/>\nChina Standard Time UT+8:00<br \/>\nCuba Standard Time UT-4:00<\/p>\n<p>\u5173\u7cfb\uff1a<br \/>\nCET = UTC\/GMT + 1\u5c0f\u65f6<br \/>\nCST = UTC\/GMT + 8\u5c0f\u65f6<br \/>\nCST = CET + 9\u5c0f\u65f6<\/p>\n<pre><code class=\"sql\">show variables like '%time_zone%';\nset time_zone='+8:00';\n<\/code><\/pre>\n<hr\/>\n<p>\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u5fae\u4fe1\u516c\u4f17\u53f7: <strong>coderbee\u7b14\u8bb0<\/strong>\uff0c\u53ef\u4ee5\u66f4\u53ca\u65f6\u56de\u590d\u4f60\u7684\u8ba8\u8bba\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"258\" height=\"258\" src=\"https:\/\/coderbee.net\/wp-content\/uploads\/2019\/01\/coderbee-note.jpg\" class=\"alignnone size-full wp-image-1707\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u95ee\u9898 \u6700\u8fd1\u78b0\u5230\u8fd9\u6837\u7684\u95ee\u9898\uff1ajdbc \u63d2\u5165 timestamp \u7c7b\u578b\u7684\u6570\u636e\u5230 My &hellip; <a href=\"https:\/\/coderbee.net\/index.php\/db\/20170418\/1501\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[268],"_links":{"self":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/1501"}],"collection":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/comments?post=1501"}],"version-history":[{"count":1,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/1501\/revisions"}],"predecessor-version":[{"id":1502,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/1501\/revisions\/1502"}],"wp:attachment":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/media?parent=1501"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/categories?post=1501"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/tags?post=1501"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}