{"id":89,"date":"2020-08-18T20:51:51","date_gmt":"2020-08-18T12:51:51","guid":{"rendered":"https:\/\/dulizao.com\/?p=89"},"modified":"2020-08-18T20:53:02","modified_gmt":"2020-08-18T12:53:02","slug":"%e9%80%9a%e8%bf%87%e6%97%b6%e9%97%b4%e5%ad%97%e7%ac%a6%e4%b8%b2%e8%8e%b7%e5%8f%96%e8%b7%9d%e7%a6%bb%e5%bd%93%e5%89%8d%e6%97%b6%e9%97%b4%e8%bf%87%e5%8e%bb%e4%ba%86%e5%a4%9a%e9%95%bf%e6%97%b6%e9%97%b4","status":"publish","type":"post","link":"https:\/\/dulizao.com\/index.php\/2020\/08\/18\/%e9%80%9a%e8%bf%87%e6%97%b6%e9%97%b4%e5%ad%97%e7%ac%a6%e4%b8%b2%e8%8e%b7%e5%8f%96%e8%b7%9d%e7%a6%bb%e5%bd%93%e5%89%8d%e6%97%b6%e9%97%b4%e8%bf%87%e5%8e%bb%e4%ba%86%e5%a4%9a%e9%95%bf%e6%97%b6%e9%97%b4\/","title":{"rendered":"\u901a\u8fc7\u65f6\u95f4\u5b57\u7b26\u4e32\u83b7\u53d6\u8ddd\u79bb\u5f53\u524d\u65f6\u95f4\u8fc7\u53bb\u4e86\u591a\u957f\u65f6\u95f4"},"content":{"rendered":"\n<pre class=\"wp-block-preformatted\">\/\/\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u65f6\u95f4\u6233\nfunction getDateTimeStamp(dateStr){\n    return <strong><em>Date<\/em><\/strong>.parse(dateStr.replace(\/-\/gi,\"\/\"));\n},\n\n\/\/\u83b7\u53d6\u6307\u5b9a\u65f6\u95f4\u8ddd\u79bb\u73b0\u5728\u8fc7\u53bb\u4e86\u591a\u5c11\u65f6\u95f4\nfunction getDateDiff(dateStr){\n    var me = this;\n    var publishTime = me.getDateTimeStamp(dateStr)\/1000,\n        d_seconds,\n        d_minutes,\n        d_hours,\n        d_days,\n        timeNow = parseInt(new <strong><em>Date<\/em><\/strong>().getTime()\/1000),\n        d,\n\n        date = new <strong><em>Date<\/em><\/strong>(publishTime*1000),\n        Y = date.getFullYear(),\n        M = date.getMonth() + 1,\n        D = date.getDate(),\n        H = date.getHours(),\n        m = date.getMinutes(),\n        s = date.getSeconds();\n    \/\/\u5c0f\u4e8e10\u7684\u5728\u524d\u9762\u88650\n    if (M &lt; 10) {\n        M = '0' + M;\n    }\n    if (D &lt; 10) {\n        D = '0' + D;\n    }\n    if (H &lt; 10) {\n        H = '0' + H;\n    }\n    if (m &lt; 10) {\n        m = '0' + m;\n    }\n    if (s &lt; 10) {\n        s = '0' + s;\n    }\n\n    d = timeNow - publishTime;\n    d_days = parseInt(d\/86400);\n    d_hours = parseInt(d\/3600);\n    d_minutes = parseInt(d\/60);\n    d_seconds = parseInt(d);\n\n    if(d_days &gt; 0 &amp;&amp; d_days &lt; 3){\n        return d_days + '\u5929\u524d';\n    }else if(d_days &lt;= 0 &amp;&amp; d_hours &gt; 0){\n        return d_hours + '\u5c0f\u65f6\u524d';\n    }else if(d_hours &lt;= 0 &amp;&amp; d_minutes &gt; 0){\n        return d_minutes + '\u5206\u949f\u524d';\n    }else if (d_seconds &lt; 60) {\n        if (d_seconds &lt;= 0) {\n            return '\u521a\u521a\u53d1\u8868';\n        }else {\n            return d_seconds + '\u79d2\u524d';\n        }\n    }else if (d_days &gt;= 3 &amp;&amp; d_days &lt; 30){\n        return M + '-' + D + '&nbsp;' + H + ':' + m;\n    }else if (d_days &gt;= 30) {\n        return Y + '-' + M + '-' + D + '&nbsp;' + H + ':' + m;\n    }\n}\n\n\/\/demo\n getDateDiff('2019-05-08 12:00:00');<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\/\/\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u65f6\u95f4\u6233 function getDateTimeStamp(dateStr){ return  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[12],"_links":{"self":[{"href":"https:\/\/dulizao.com\/index.php\/wp-json\/wp\/v2\/posts\/89"}],"collection":[{"href":"https:\/\/dulizao.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dulizao.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dulizao.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dulizao.com\/index.php\/wp-json\/wp\/v2\/comments?post=89"}],"version-history":[{"count":2,"href":"https:\/\/dulizao.com\/index.php\/wp-json\/wp\/v2\/posts\/89\/revisions"}],"predecessor-version":[{"id":91,"href":"https:\/\/dulizao.com\/index.php\/wp-json\/wp\/v2\/posts\/89\/revisions\/91"}],"wp:attachment":[{"href":"https:\/\/dulizao.com\/index.php\/wp-json\/wp\/v2\/media?parent=89"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dulizao.com\/index.php\/wp-json\/wp\/v2\/categories?post=89"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dulizao.com\/index.php\/wp-json\/wp\/v2\/tags?post=89"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}