{"id":7752,"date":"2024-07-07T17:01:03","date_gmt":"2024-07-07T09:01:03","guid":{"rendered":""},"modified":"2024-07-07T17:01:03","modified_gmt":"2024-07-07T09:01:03","slug":"js\u5b9e\u73b0\u5012\u8ba1\u65f660s_js\u5012\u8ba1\u65f660\u79d2\u9875\u9762\u663e\u793a","status":"publish","type":"post","link":"https:\/\/mushiming.com\/7752.html","title":{"rendered":"js\u5b9e\u73b0\u5012\u8ba1\u65f660s_js\u5012\u8ba1\u65f660\u79d2\u9875\u9762\u663e\u793a"},"content":{"rendered":"
\n\u901a\u8fc7Date()<\/span>\u51fd\u6570\u548cInterval()<\/span>\u51fd\u6570\u7ed3\u5408\u6c34\u4ed9\u82b1\u6570<\/span>\u539f\u7406\u6c42\u65f6\u95f4\u52a8\u6001\u53d8\u5316\u5b9e\u73b0\u65f6\u95f4\u51cf\u51cf\u5012\u8ba1\u65f6<\/h2>\n<\/blockquote>\n
\u5b9e\u73b0\u4ee3\u7801\u5982\u4e0b<\/span><\/strong><\/h4>\n
<!DOCTYPE html>\n<html>\n\n<head>\n <title>\u5012\u8ba1\u65f6\u793a\u4f8b<\/title>\n<\/head>\n\n<body>\n <div id=\"countdown\"><\/div>\n\n <script>\n var countdownElement = document.getElementById('countdown');\n var endTime = new Date(); \/\/ \u83b7\u53d6\u5f53\u524d\u65f6\u95f4\n endTime.setHours(endTime.getHours() + 2); \/\/ \u8bbe\u7f6e\u8003\u8bd5\u7ed3\u675f\u65f6\u95f4\u4e3a2\u5c0f\u65f6\u540e\n\n function updateCountdown() {\n var now = new Date(); \/\/ \u83b7\u53d6\u5f53\u524d\u65f6\u95f4\n var timeDiff = endTime - now; \/\/ \u8ba1\u7b97\u5269\u4f59\u65f6\u95f4\u7684\u6beb\u79d2\u6570\n\n if (timeDiff <= 0) {\n clearInterval(timer); \/\/ \u5012\u8ba1\u65f6\u7ed3\u675f\uff0c\u6e05\u9664\u5b9a\u65f6\u5668\n countdownElement.innerHTML = \"\u8003\u8bd5\u65f6\u95f4\u7ed3\u675f!\";\n } else {\n var hours = Math.floor(timeDiff \/ 3600000); \/\/ \u8ba1\u7b97\u5269\u4f59\u5c0f\u65f6\u6570\n var minutes = Math.floor((timeDiff % 3600000) \/ 60000); \/\/ \u8ba1\u7b97\u5269\u4f59\u5206\u949f\u6570\n var seconds = Math.floor((timeDiff % 60000) \/ 1000); \/\/ \u8ba1\u7b97\u5269\u4f59\u79d2\u6570\n\n hours = (hours < 10) ? \"0\" + hours : hours;\n minutes = (minutes < 10) ? \"0\" + minutes : minutes;\n seconds = (seconds < 10) ? \"0\" + seconds : seconds;\n\n var countdownDisplay = hours + \":\" + minutes + \":\" + seconds;\n countdownElement.innerHTML = \"\u8003\u8bd5\u5012\u8ba1\u65f6\uff1a\" + countdownDisplay;\n }\n }\n\n updateCountdown(); \/\/ \u9996\u6b21\u8c03\u7528\u66f4\u65b0\u5012\u8ba1\u65f6\n var timer = setInterval(updateCountdown, 1000); \/\/ \u6bcf\u79d2\u8c03\u7528\u4e00\u6b21\u66f4\u65b0\u5012\u8ba1\u65f6\n\n <\/script>\n<\/body>\n\n<\/html><\/code><\/pre>\n
\u5b9e\u73b0\u6548\u679c\u5982\u4e0b<\/strong><\/h4>\n
<\/strong><\/p><\/p>\n","protected":false},"excerpt":{"rendered":"js\u5b9e\u73b0\u5012\u8ba1\u65f660s_js\u5012\u8ba1\u65f660\u79d2\u9875\u9762\u663e\u793aDate()Interval()\u6c34\u4ed9\u82b1\u6570Date()_countdown.js","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/7752"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=7752"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/7752\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=7752"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=7752"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=7752"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}