{"id":6234,"date":"2024-11-14T11:10:09","date_gmt":"2024-11-14T03:10:09","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6234\/"},"modified":"2024-11-14T11:10:09","modified_gmt":"2024-11-14T03:10:09","slug":"%e5%a6%82%e4%bd%95%e8%8e%b7%e5%8f%96mysql%e7%9a%84%e6%97%b6%e9%97%b4%e6%88%b3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6234\/","title":{"rendered":"\u5982\u4f55\u83b7\u53d6mysql\u7684\u65f6\u95f4\u6233"},"content":{"rendered":"<blockquote><p>\n  mysql \u83b7\u53d6\u65f6\u95f4\u6233\u7684\u65b9\u6cd5\u6709\uff1a1. now() \u51fd\u6570\u8fd4\u56de\u5f53\u524d\u65f6\u95f4\u6233\uff1b2. current_timestamp \u51fd\u6570\u4e5f\u8fd4\u56de\u5f53\u524d\u65f6\u95f4\u6233\uff1b3. unix_timestamp() \u51fd\u6570\u8f6c\u6362\u4e3a unix \u65f6\u95f4\u6233\uff1b4. from_unixtime() \u51fd\u6570\u5c06 unix \u65f6\u95f4\u6233\u8f6c\u6362\u4e3a\u53ef\u8bfb\u65f6\u95f4\u6233\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/15\/2024061515302793351.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u83b7\u53d6mysql\u7684\u65f6\u95f4\u6233\u63d2\u56fe\" alt=\"\u5982\u4f55\u83b7\u53d6mysql\u7684\u65f6\u95f4\u6233\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u83b7\u53d6 MySQL \u65f6\u95f4\u6233<\/strong><\/p>\n<p>MySQL \u63d0\u4f9b\u4e86\u591a\u79cd\u65b9\u6cd5\u6765\u83b7\u53d6\u65f6\u95f4\u6233\uff0c\u5305\u62ec\uff1a<\/p>\n<p><strong>1. NOW() \u51fd\u6570<\/strong><\/p>\n<p>NOW() \u51fd\u6570\u8fd4\u56de\u5f53\u524d\u65f6\u95f4\u6233\uff1a<\/p>\n<pre>SELECT NOW();<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. CURRENT_TIMESTAMP \u51fd\u6570<\/strong><\/p>\n<p>CURRENT_TIMESTAMP \u51fd\u6570\u4e5f\u8fd4\u56de\u5f53\u524d\u65f6\u95f4\u6233\uff1a<\/p>\n<pre>SELECT CURRENT_TIMESTAMP;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3. UNIX_TIMESTAMP() \u51fd\u6570<\/strong><\/p>\n<p>UNIX_TIMESTAMP() \u51fd\u6570\u5c06\u65f6\u95f4\u6233\u8f6c\u6362\u4e3a Unix \u65f6\u95f4\u6233\uff08\u81ea 1970 \u5e74 1 \u6708 1 \u65e5\u5348\u591c\u4ee5\u6765\u7684\u79d2\u6570\uff09\uff1a<\/p>\n<pre>SELECT UNIX_TIMESTAMP();<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>4. FROM_UNIXTIME() \u51fd\u6570<\/strong><\/p>\n<p>FROM_UNIXTIME() \u51fd\u6570\u5c06 Unix \u65f6\u95f4\u6233\u8f6c\u6362\u4e3a\u53ef\u8bfb\u65f6\u95f4\u6233\uff1a<\/p>\n<pre>SELECT FROM_UNIXTIME(1656045000);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u5176\u4ed6\u63d0\u793a\uff1a<\/strong><\/p>\n<ul>\n<li>\u8fd9\u4e9b\u51fd\u6570\u90fd\u8fd4\u56de\u4e00\u4e2a TIMESTAMP \u6570\u636e\u7c7b\u578b\u7684\u503c\u3002<\/li>\n<li>\u65f6\u95f4\u6233\u53ef\u4ee5\u7528\u4e8e\u6807\u8bb0\u4e8b\u4ef6\u53d1\u751f\u7684\u65f6\u95f4\u6216\u8ddf\u8e2a\u6570\u636e\u66f4\u6539\u3002<\/li>\n<li>\u53ef\u4ee5\u4f7f\u7528 DATE_FORMAT() \u51fd\u6570\u5c06\u65f6\u95f4\u6233\u683c\u5f0f\u5316\u4e3a\u6240\u9700\u7684\u683c\u5f0f\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u83b7\u53d6\u7684\u65f6\u95f4\u6233\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>mysql \u83b7\u53d6\u65f6\u95f4\u6233\u7684\u65b9\u6cd5\u6709\uff1a1. now() \u51fd\u6570\u8fd4\u56de\u5f53\u524d\u65f6\u95f4\u6233\uff1b2. current_timestamp \u51fd\u6570\u4e5f\u8fd4\u56de\u5f53\u524d\u65f6\u95f4\u6233\uff1b3. unix_timestamp() \u51fd\u6570\u8f6c\u6362\u4e3a unix \u65f6\u95f4\u6233\uff1b4. from_unixtime() \u51fd\u6570\u5c06 unix \u65f6\u95f4\u6233\u8f6c\u6362\u4e3a\u53ef\u8bfb\u65f6\u95f4\u6233\u3002 \u5982\u4f55\u83b7\u53d6 MySQL \u65f6\u95f4\u6233 MySQL \u63d0\u4f9b\u4e86\u591a\u79cd\u65b9\u6cd5\u6765\u83b7\u53d6\u65f6\u95f4\u6233\uff0c\u5305\u62ec\uff1a 1. NOW() \u51fd\u6570 NOW() \u51fd\u6570\u8fd4\u56de\u5f53\u524d\u65f6\u95f4\u6233\uff1a SELECT NOW(); \u767b\u5f55\u540e\u590d\u5236 2. CURRENT_TIMESTAMP \u51fd\u6570 CURRENT_TIMESTAMP \u51fd\u6570\u4e5f\u8fd4\u56de\u5f53\u524d\u65f6\u95f4\u6233\uff1a SELECT CURRENT_TIMESTAMP; \u767b\u5f55\u540e\u590d\u5236 3. UNIX_TIMESTAMP() \u51fd\u6570 UNIX_TIMESTAMP() \u51fd\u6570\u5c06\u65f6\u95f4\u6233\u8f6c\u6362\u4e3a Unix \u65f6\u95f4\u6233\uff08\u81ea 1970 \u5e74 1 \u6708 1 \u65e5\u5348\u591c\u4ee5\u6765\u7684\u79d2\u6570\uff09\uff1a SELECT UNIX_TIMESTAMP(); \u767b\u5f55\u540e\u590d\u5236 4. FROM_UNIXTIME() \u51fd\u6570 FROM_UNIXTIME() [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-6234","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6234","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=6234"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6234\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6234"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6234"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6234"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}