{"id":1789,"date":"2024-11-10T10:10:23","date_gmt":"2024-11-10T02:10:23","guid":{"rendered":"https:\/\/fwq.ai\/blog\/1789\/"},"modified":"2024-11-10T10:10:23","modified_gmt":"2024-11-10T02:10:23","slug":"%e5%a6%82%e4%bd%95%e5%88%a4%e6%96%ad%e5%bd%93%e5%89%8d%e6%97%b6%e9%97%b4%e8%b7%9d%e7%a6%bb%e6%9f%90%e4%b8%aa%e6%97%a5%e6%9c%9f%e8%bf%98%e6%9c%89-9-%e4%b8%aa%e6%9c%88%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/1789\/","title":{"rendered":"\u5982\u4f55\u5224\u65ad\u5f53\u524d\u65f6\u95f4\u8ddd\u79bb\u67d0\u4e2a\u65e5\u671f\u8fd8\u6709 9 \u4e2a\u6708\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173059272545343.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u5224\u65ad\u5f53\u524d\u65f6\u95f4\u8ddd\u79bb\u67d0\u4e2a\u65e5\u671f\u8fd8\u6709 9 \u4e2a\u6708\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u5224\u65ad\u5f53\u524d\u65f6\u95f4\u8ddd\u79bb\u67d0\u4e2a\u65e5\u671f\u8fd8\u6709 9 \u4e2a\u6708\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u6839\u636e\u5230\u671f\u65f6\u95f4\u5224\u65ad\u662f\u5426\u8fd8\u6709 9 \u4e2a\u6708<\/strong><\/p>\n<p>\u4e3a\u4e86\u5224\u65ad\u5f53\u524d\u5e74\u4efd\u662f\u5426\u4e0e\u5230\u671f\u5e74\u4efd\u4e00\u81f4\uff0c\u5e76\u4e14\u8ddd\u79bb\u5230\u671f\u6708\u4efd\u8fd8\u6709 9 \u4e2a\u6708\u5185\uff0c\u53ef\u4ee5\u4f7f\u7528 JavaScript \u4ee3\u7801\u5b9e\u73b0\u4ee5\u4e0b\u903b\u8f91\uff1a<\/p>\n<ol>\n<li>\u5b9a\u4e49\u4e00\u4e2a\u51fd\u6570 isDistance9 \u63a5\u6536\u4e00\u4e2a\u5230\u671f\u65f6\u95f4\uff08\u683c\u5f0f\u4e3a yy-mm-dd\uff09\uff1a<\/li>\n<li>\u5c06\u5230\u671f\u65f6\u95f4\u8f6c\u6362\u4e3a Date \u5bf9\u8c61\uff08const d = new Date(end)\uff09<\/li>\n<li>\u5c06\u5f53\u524d\u65f6\u95f4\u8f6c\u6362\u4e3a Date \u5bf9\u8c61\uff08const now = new Date()\uff09<\/li>\n<li>\u8ba1\u7b97\u4e24\u4e2a\u6708\u4efd\u4e4b\u95f4\u7684\u5dee\u503c\uff08const difMonth = d.getMonth() &#8211; now.getMonth()\uff09<\/li>\n<li>\u6bd4\u8f83\u5e74\u4efd\u662f\u5426\u76f8\u7b49\uff08now.getFullYear() == d.getFullYear()\uff09<\/li>\n<li>\u6bd4\u8f83\u6708\u4efd\u5dee\u503c\u662f\u5426\u5728 0 \u5230 9 \u4e2a\u6708\u5185\uff08difMonth = 0\uff09<\/li>\n<\/ol>\n<p>\u5982\u679c\u6ee1\u8db3\u4ee5\u4e0a\u6761\u4ef6\uff0c\u5219\u51fd\u6570\u8fd4\u56de true\uff0c\u5426\u5219\u8fd4\u56de false\u3002<\/p>\n<p>\u4ee5\u4e0b\u793a\u4f8b\u4ee3\u7801\u6f14\u793a\u4e86\u5982\u4f55\u4f7f\u7528\u8be5\u51fd\u6570\uff1a<\/p>\n<pre>const isDistance9 = end =&gt; {\n    const d = new Date(end);\n    const now = new Date();\n    const difMonth = d.getMonth() - now.getMonth()\n    return now.getFullYear() == d.getFullYear() &amp;&amp; difMonth&lt;=9 &amp;&amp; difMonth&gt;=0\n}\n\nconsole.log(isDistance9('2023-08-01')) \/\/ true\nconsole.log(isDistance9('2024-08-01')) \/\/ false<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5224\u65ad\u5f53\u524d\u65f6\u95f4\u8ddd\u79bb\u67d0\u4e2a\u65e5\u671f\u8fd8\u6709 9 \u4e2a\u6708\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6839\u636e\u5230\u671f\u65f6\u95f4\u5224\u65ad\u662f\u5426\u8fd8\u6709 9 \u4e2a\u6708 \u4e3a\u4e86\u5224\u65ad\u5f53\u524d\u5e74\u4efd\u662f\u5426\u4e0e\u5230\u671f\u5e74\u4efd\u4e00\u81f4\uff0c\u5e76\u4e14\u8ddd\u79bb\u5230\u671f\u6708\u4efd\u8fd8\u6709 9 \u4e2a\u6708\u5185\uff0c\u53ef\u4ee5\u4f7f\u7528 JavaScript \u4ee3\u7801\u5b9e\u73b0\u4ee5\u4e0b\u903b\u8f91\uff1a \u5b9a\u4e49\u4e00\u4e2a\u51fd\u6570 isDistance9 \u63a5\u6536\u4e00\u4e2a\u5230\u671f\u65f6\u95f4\uff08\u683c\u5f0f\u4e3a yy-mm-dd\uff09\uff1a \u5c06\u5230\u671f\u65f6\u95f4\u8f6c\u6362\u4e3a Date \u5bf9\u8c61\uff08const d = new Date(end)\uff09 \u5c06\u5f53\u524d\u65f6\u95f4\u8f6c\u6362\u4e3a Date \u5bf9\u8c61\uff08const now = new Date()\uff09 \u8ba1\u7b97\u4e24\u4e2a\u6708\u4efd\u4e4b\u95f4\u7684\u5dee\u503c\uff08const difMonth = d.getMonth() &#8211; now.getMonth()\uff09 \u6bd4\u8f83\u5e74\u4efd\u662f\u5426\u76f8\u7b49\uff08now.getFullYear() == d.getFullYear()\uff09 \u6bd4\u8f83\u6708\u4efd\u5dee\u503c\u662f\u5426\u5728 0 \u5230 9 \u4e2a\u6708\u5185\uff08difMonth = 0\uff09 \u5982\u679c\u6ee1\u8db3\u4ee5\u4e0a\u6761\u4ef6\uff0c\u5219\u51fd\u6570\u8fd4\u56de true\uff0c\u5426\u5219\u8fd4\u56de false\u3002 \u4ee5\u4e0b\u793a\u4f8b\u4ee3\u7801\u6f14\u793a\u4e86\u5982\u4f55\u4f7f\u7528\u8be5\u51fd\u6570\uff1a const isDistance9 = end =&gt; { const d = [&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-1789","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1789","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=1789"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1789\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=1789"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=1789"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=1789"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}