<tfoot id='tGp7n'></tfoot>
<i id='tGp7n'><tr id='tGp7n'><dt id='tGp7n'><q id='tGp7n'><span id='tGp7n'><b id='tGp7n'><form id='tGp7n'><ins id='tGp7n'></ins><ul id='tGp7n'></ul><sub id='tGp7n'></sub></form><legend id='tGp7n'></legend><bdo id='tGp7n'><pre id='tGp7n'><center id='tGp7n'></center></pre></bdo></b><th id='tGp7n'></th></span></q></dt></tr></i><div id='tGp7n'><tfoot id='tGp7n'></tfoot><dl id='tGp7n'><fieldset id='tGp7n'></fieldset></dl></div>

<legend id='tGp7n'><style id='tGp7n'><dir id='tGp7n'><q id='tGp7n'></q></dir></style></legend>
          <bdo id='tGp7n'></bdo><ul id='tGp7n'></ul>

        <small id='tGp7n'></small><noframes id='tGp7n'>

      1. JavaScript 添加天数

        时间:2023-09-05

      2. <small id='OLd8m'></small><noframes id='OLd8m'>

        • <tfoot id='OLd8m'></tfoot>
            <bdo id='OLd8m'></bdo><ul id='OLd8m'></ul>
            <i id='OLd8m'><tr id='OLd8m'><dt id='OLd8m'><q id='OLd8m'><span id='OLd8m'><b id='OLd8m'><form id='OLd8m'><ins id='OLd8m'></ins><ul id='OLd8m'></ul><sub id='OLd8m'></sub></form><legend id='OLd8m'></legend><bdo id='OLd8m'><pre id='OLd8m'><center id='OLd8m'></center></pre></bdo></b><th id='OLd8m'></th></span></q></dt></tr></i><div id='OLd8m'><tfoot id='OLd8m'></tfoot><dl id='OLd8m'><fieldset id='OLd8m'></fieldset></dl></div>
              <legend id='OLd8m'><style id='OLd8m'><dir id='OLd8m'><q id='OLd8m'></q></dir></style></legend>

                <tbody id='OLd8m'></tbody>

                  本文介绍了JavaScript 添加天数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  如何在日期 31.07.2012 中添加一天(或 2 天)并以 dd.MM.yyyy 格式(与输入日期格式相同)返回结果?

                  How to add a day (or 2 days) to date 31.07.2012 and return result in format dd.MM.yyyy (same format as input date)?

                  推荐答案

                      var numDaysToAdd = 2;
                      var inputDateString = "31.07.2012";
                      var resultDate = stringToDate(inputDateString);
                      resultDate.setDate( resultDate.getDate()+numDaysToAdd );
                      var result = dateToString( resultDate );
                  
                  
                      alert(result);
                  
                      function stringToDate( aString )
                      {
                          var dateArray = aString.split(".");
                          return new Date(dateArray[2],dateArray[1]-1,dateArray[0]);
                      }
                  
                      function dateToString( aDate )
                      {
                          var date = aDate.getDate();
                          date = (date > 9) ? date : "0"+date.toString();
                  
                          var month = aDate.getMonth()+1;
                          month = (month > 9) ? month : "0"+month.toString();
                  
                          var year = aDate.getFullYear();
                  
                  
                          return (date+"."+month+"."+year);
                      }
                  

                  这篇关于JavaScript 添加天数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:识别网页中所选文本是否为粗体 下一篇:Angular 中的货币格式化指令

                  相关文章

                  最新文章

                    <legend id='cP3G8'><style id='cP3G8'><dir id='cP3G8'><q id='cP3G8'></q></dir></style></legend>

                    <tfoot id='cP3G8'></tfoot>
                    <i id='cP3G8'><tr id='cP3G8'><dt id='cP3G8'><q id='cP3G8'><span id='cP3G8'><b id='cP3G8'><form id='cP3G8'><ins id='cP3G8'></ins><ul id='cP3G8'></ul><sub id='cP3G8'></sub></form><legend id='cP3G8'></legend><bdo id='cP3G8'><pre id='cP3G8'><center id='cP3G8'></center></pre></bdo></b><th id='cP3G8'></th></span></q></dt></tr></i><div id='cP3G8'><tfoot id='cP3G8'></tfoot><dl id='cP3G8'><fieldset id='cP3G8'></fieldset></dl></div>

                      • <bdo id='cP3G8'></bdo><ul id='cP3G8'></ul>
                    1. <small id='cP3G8'></small><noframes id='cP3G8'>