{"id":2194,"date":"2017-10-19T16:35:00","date_gmt":"2017-10-19T08:35:00","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=2194"},"modified":"2017-10-19T16:35:00","modified_gmt":"2017-10-19T08:35:00","slug":"javascript%e8%ae%a1%e7%ae%97%e5%b9%b6%e8%8e%b7%e5%8f%96%e6%97%a5%e5%8e%86%e7%9a%84%e4%b8%8a%e4%b8%80%e4%b8%aa%e6%9c%88%e5%92%8c%e4%b8%8b%e4%b8%80%e4%b8%aa%e6%9c%88","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=2194","title":{"rendered":"javascript\u8ba1\u7b97\u5e76\u83b7\u53d6\u65e5\u5386\u7684\u4e0a\u4e00\u4e2a\u6708\u548c\u4e0b\u4e00\u4e2a\u6708"},"content":{"rendered":"<p>\n\t\u5728\u5b9e\u9645\u7684\u5f00\u53d1\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u4f1a\u9047\u5230\u9700\u8981\u83b7\u53d6\u4e0a\u4e00\u4e2a\u6708\uff0c\u4e0b\u4e00\u4e2a\u6708\u7684\u65f6\u95f4\uff0c\u65e5\u671f\u7684\u60c5\u51b5\u3002\u56e0\u6b64\u6211\u8fd9\u91cc\u6574\u7406\u4e86\u4e24\u4e2a\u83b7\u53d6\u4e0a\u4e0b\u6708\u65f6\u95f4\u7684js\u65b9\u6cd5\uff0c\u5206\u4eab\u7ed9\u5927\u5bb6\u3002\n<\/p>\n<pre class=\"brush:jscript;\">\r\n\/**\r\n * \u83b7\u53d6\u4e0a\u4e00\u4e2a\u6708\r\n * @date \u683c\u5f0f\u4e3ayyyy-mm-dd\u7684\u65e5\u671f\uff0c\u5982\uff1a2014-01-25\r\n *\/\r\nfunction getPreMonth(date) {\r\n\tvar arr = date.split(&#039;-&#039;);\r\n\tvar year = arr[0]; \/\/\u83b7\u53d6\u5f53\u524d\u65e5\u671f\u7684\u5e74\u4efd\r\n\tvar month = arr[1]; \/\/\u83b7\u53d6\u5f53\u524d\u65e5\u671f\u7684\u6708\u4efd\r\n\tvar day = arr[2]; \/\/\u83b7\u53d6\u5f53\u524d\u65e5\u671f\u7684\u65e5\r\n\tvar days = new Date(year, month, 0);\r\n\tdays = days.getDate(); \/\/\u83b7\u53d6\u5f53\u524d\u65e5\u671f\u4e2d\u6708\u7684\u5929\u6570\r\n\tvar year2 = year;\r\n\tvar month2 = parseInt(month) - 1;\r\n\tif (month2 == 0) {\r\n\t\tyear2 = parseInt(year2) - 1;\r\n\t\tmonth2 = 12;\r\n\t}\r\n\tvar day2 = day;\r\n\tvar days2 = new Date(year2, month2, 0);\r\n\tdays2 = days2.getDate();\r\n\tif (day2 &gt; days2) {\r\n\t\tday2 = days2;\r\n\t}\r\n\tif (month2 &lt; 10) {\r\n\t\tmonth2 = &#039;0&#039; + month2;\r\n\t}\r\n\tvar t2 = year2 + &#039;-&#039; + month2 + &#039;-&#039; + day2;\r\n\treturn t2;\r\n}\r\n\/**\r\n * \u83b7\u53d6\u4e0b\u4e00\u4e2a\u6708\r\n * @date \u683c\u5f0f\u4e3ayyyy-mm-dd\u7684\u65e5\u671f\uff0c\u5982\uff1a2014-01-25\r\n *\/        \r\nfunction getNextMonth(date) {\r\n\tvar arr = date.split(&#039;-&#039;);\r\n\tvar year = arr[0]; \/\/\u83b7\u53d6\u5f53\u524d\u65e5\u671f\u7684\u5e74\u4efd\r\n\tvar month = arr[1]; \/\/\u83b7\u53d6\u5f53\u524d\u65e5\u671f\u7684\u6708\u4efd\r\n\tvar day = arr[2]; \/\/\u83b7\u53d6\u5f53\u524d\u65e5\u671f\u7684\u65e5\r\n\tvar days = new Date(year, month, 0);\r\n\tdays = days.getDate(); \/\/\u83b7\u53d6\u5f53\u524d\u65e5\u671f\u4e2d\u7684\u6708\u7684\u5929\u6570\r\n\tvar year2 = year;\r\n\tvar month2 = parseInt(month) + 1;\r\n\tif (month2 == 13) {\r\n\t\tyear2 = parseInt(year2) + 1;\r\n\t\tmonth2 = 1;\r\n\t}\r\n\tvar day2 = day;\r\n\tvar days2 = new Date(year2, month2, 0);\r\n\tdays2 = days2.getDate();\r\n\tif (day2 &gt; days2) {\r\n\t\tday2 = days2;\r\n\t}\r\n\tif (month2 &lt; 10) {\r\n\t\tmonth2 = &#039;0&#039; + month2;\r\n\t}\r\n\tvar t2 = year2 + &#039;-&#039; + month2 + &#039;-&#039; + day2;\r\n\treturn t2;\r\n}\r\n\/\/\u6d4b\u8bd5        \r\n\/\/alert(getPreMonth(&quot;2014-01-25&quot;));\r\n\/\/alert(getNextMonth(&quot;2014-12-25&quot;));\r\n<\/pre>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=2194\">javascript\u8ba1\u7b97\u5e76\u83b7\u53d6\u65e5\u5386\u7684\u4e0a\u4e00\u4e2a\u6708\u548c\u4e0b\u4e00\u4e2a\u6708<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u5728\u5b9e\u9645\u7684\u5f00\u53d1\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u4f1a\u9047\u5230\u9700\u8981\u83b7\u53d6\u4e0a\u4e00\u4e2a\u6708\uff0c\u4e0b\u4e00\u4e2a\u6708\u7684\u65f6\u95f4\uff0c\u65e5\u671f\u7684\u60c5\u51b5\u3002\u56e0\u6b64\u6211\u8fd9\u91cc\u6574\u7406\u4e86\u4e24\u4e2a\u83b7\u53d6\u4e0a\u4e0b\u6708\u65f6\u95f4 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[260,619,1106],"class_list":["post-2194","post","type-post","status-publish","format-standard","hentry","category-html5","tag-bootstrap-datetimepicker","tag-date-api","tag-javascript"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2194","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2194"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2194\/revisions"}],"predecessor-version":[{"id":2195,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2194\/revisions\/2195"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2194"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2194"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2194"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}