{"id":1337,"date":"2024-11-10T09:24:22","date_gmt":"2024-11-10T01:24:22","guid":{"rendered":"https:\/\/fwq.ai\/blog\/1337\/"},"modified":"2024-11-10T09:24:22","modified_gmt":"2024-11-10T01:24:22","slug":"%e5%a6%82%e4%bd%95%e7%94%a8-javascript-%e6%a0%b9%e6%8d%ae%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%97%b6%e9%97%b4%e6%88%b3%e5%88%9b%e5%bb%ba%e7%a7%92%e7%ba%a7%e5%80%92%e8%ae%a1%e6%97%b6%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/1337\/","title":{"rendered":"\u5982\u4f55\u7528 JavaScript \u6839\u636e\u670d\u52a1\u5668\u65f6\u95f4\u6233\u521b\u5efa\u79d2\u7ea7\u5012\u8ba1\u65f6\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173037151223517.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u7528 JavaScript \u6839\u636e\u670d\u52a1\u5668\u65f6\u95f4\u6233\u521b\u5efa\u79d2\u7ea7\u5012\u8ba1\u65f6\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u7528 JavaScript \u6839\u636e\u670d\u52a1\u5668\u65f6\u95f4\u6233\u521b\u5efa\u79d2\u7ea7\u5012\u8ba1\u65f6\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u7528 javascript \u6839\u636e\u670d\u52a1\u5668\u8fd4\u56de\u7684\u65f6\u95f4\u6233\u521b\u5efa\u5012\u8ba1\u65f6\uff0c\u53ea\u8ba1\u7b97\u5269\u4f59\u79d2\u6570<\/strong><\/p>\n<p>\u5728 JavaScript \u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u670d\u52a1\u5668\u8fd4\u56de\u7684\u521b\u5efa\u65f6\u95f4\u6233\uff0c\u8ba1\u7b97\u5269\u4f59\u7684\u79d2\u6570\u3002\u4ee5\u4e0b\u662f\u5b9e\u73b0\u65b9\u6cd5\uff1a<\/p>\n<pre>let createAt = 1666865462286 + (180*1000); \/\/ \u5c06 1666865462286 \u66ff\u6362\u4e3a\u521b\u5efa\u65f6\u95f4\u6233\n\nsetInterval(() =&gt; {\n    let currentTime = new Date().getTime();\n    let time = parseInt((createAt - currentTime) \/ 1000);\n    console.log(`\u5269\u4f59${time}\u79d2`);\n}, 1000);<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u8bf4\u660e\uff1a<\/strong><\/p>\n<ul>\n<li>createAt \u662f\u670d\u52a1\u5668\u8fd4\u56de\u7684\u521b\u5efa\u65f6\u95f4\u6233\uff08\u4ee5\u6beb\u79d2\u4e3a\u5355\u4f4d\uff09\u3002<\/li>\n<li>setInterval() \u51fd\u6570\u6bcf\u79d2\u6267\u884c\u4e00\u6b21\u56de\u8c03\u51fd\u6570\u3002<\/li>\n<li>\u5728\u56de\u8c03\u51fd\u6570\u4e2d\uff0c\u6211\u4eec\u83b7\u53d6\u5f53\u524d\u65f6\u95f4\u6233\uff08currentTime\uff09\uff0c\u7136\u540e\u8ba1\u7b97\u5269\u4f59\u7684\u79d2\u6570\uff08time\uff09\u3002<\/li>\n<li>\u6700\u540e\uff0c\u6211\u4eec\u5728\u63a7\u5236\u53f0\u4e2d\u8f93\u51fa\u5269\u4f59\u7684\u79d2\u6570\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u7528 JavaScript \u6839\u636e\u670d\u52a1\u5668\u65f6\u95f4\u6233\u521b\u5efa\u79d2\u7ea7\u5012\u8ba1\u65f6\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>\u5982\u4f55\u7528 javascript \u6839\u636e\u670d\u52a1\u5668\u8fd4\u56de\u7684\u65f6\u95f4\u6233\u521b\u5efa\u5012\u8ba1\u65f6\uff0c\u53ea\u8ba1\u7b97\u5269\u4f59\u79d2\u6570 \u5728 JavaScript \u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u670d\u52a1\u5668\u8fd4\u56de\u7684\u521b\u5efa\u65f6\u95f4\u6233\uff0c\u8ba1\u7b97\u5269\u4f59\u7684\u79d2\u6570\u3002\u4ee5\u4e0b\u662f\u5b9e\u73b0\u65b9\u6cd5\uff1a let createAt = 1666865462286 + (180*1000); \/\/ \u5c06 1666865462286 \u66ff\u6362\u4e3a\u521b\u5efa\u65f6\u95f4\u6233 setInterval(() =&gt; { let currentTime = new Date().getTime(); let time = parseInt((createAt &#8211; currentTime) \/ 1000); console.log(`\u5269\u4f59${time}\u79d2`); }, 1000); \u767b\u5f55\u540e\u590d\u5236 \u8bf4\u660e\uff1a createAt \u662f\u670d\u52a1\u5668\u8fd4\u56de\u7684\u521b\u5efa\u65f6\u95f4\u6233\uff08\u4ee5\u6beb\u79d2\u4e3a\u5355\u4f4d\uff09\u3002 setInterval() \u51fd\u6570\u6bcf\u79d2\u6267\u884c\u4e00\u6b21\u56de\u8c03\u51fd\u6570\u3002 \u5728\u56de\u8c03\u51fd\u6570\u4e2d\uff0c\u6211\u4eec\u83b7\u53d6\u5f53\u524d\u65f6\u95f4\u6233\uff08currentTime\uff09\uff0c\u7136\u540e\u8ba1\u7b97\u5269\u4f59\u7684\u79d2\u6570\uff08time\uff09\u3002 \u6700\u540e\uff0c\u6211\u4eec\u5728\u63a7\u5236\u53f0\u4e2d\u8f93\u51fa\u5269\u4f59\u7684\u79d2\u6570\u3002 \u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u7528 JavaScript \u6839\u636e\u670d\u52a1\u5668\u65f6\u95f4\u6233\u521b\u5efa\u79d2\u7ea7\u5012\u8ba1\u65f6\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},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-1337","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1337","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=1337"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1337\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=1337"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=1337"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=1337"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}