<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## 問題 Problem 你需要獲取兩個日期之間差了多少分鐘,或者是差了多少小時、天、月和年? You need to find how much seconds minutes, hours, days, months or years has passed between two dates. ## 方法 Solution 使用JavaScript Date的`getTime()`方法,該方法會返回從01/01/1970到現在過去的毫秒數。 Use JavaScript’s Date function?`getTime()`. Which provides how much time in miliseconds has passed since 01/01/1970: ~~~ DAY = 1000 * 60 * 60 * 24 d1 = new Date('02/01/2011') d2 = new Date('02/06/2011') days_passed = Math.round((d2.getTime() - d1.getTime()) / DAY) ~~~ ## 討論 Discussion 使用毫秒避免了使用Date溢出的錯誤。因此我們首先計算出一天包含多少毫秒。然后,給定兩個不一樣的日期,只需獲取這兩個日期相差的毫秒數,再除以一天包含的毫秒數,就可以得到這兩個日期之間包含了多少天。 Using miliseconds makes the life easier to avoid overflow mistakes with Dates. So we first calculate how much miliseconds has a day. Then, given two distincit dates, just get the diference in miliseconds betwen two dates and then divide by how much miliseconds has a day. It will get you the days between two distinct dates. 如果你想要計算兩個日期隔了多少小時,你只需要除以一小時的毫秒數就行。分鐘和秒數如法炮制。 If you’d like to calculate the hours between two dates objects you can do that just by dividing the diference in miliseconds by the convertion of miliseconds to hours. The same goes to minutes and seconds. ~~~ HOUR = 1000 * 60 * 60 d1 = new Date('02/01/2011 02:20') d2 = new Date('02/06/2011 05:20') hour_passed = Math.round((d2.getTime() - d1.getTime()) / HOUR) ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看