Loading...

          java .net

          javascript 將給定日期增加n個月

          //將給定日期增加NumDay個月
              function addDate(dtDate,NumDay){
                  var date = new Date(dtDate);
                  var lIntval = parseInt(NumDay);
                  date.setMonth(date.getMonth() + lIntval);
                  return date.getYear() +'-' + (date.getMonth()+1) + '-' +date.getDate();
              }

          addDate("2008-01-01".replace(/-/g, "\/"),2);


          =======================================
          // addDate("5",5,"2004/12/1 00:00:00")
          function addDate(type,NumDay,dtDate){
             var date = new Date(dtDate)
          type = parseInt(type) //類型
          lIntval = parseInt(NumDay)//間隔
          switch(type){
             case 6 ://年
          date.setYear(date.getYear() + lIntval)
          break;
          case 7 ://季度
          date.setMonth(date.getMonth() + (lIntval * 3) )
          break;
          case 5 ://月
          date.setMonth(date.getMonth() + lIntval)
          break;
          case 4 ://天
          date.setDate(date.getDate() + lIntval)
          break
          case 3 ://時
          date.setHours(date.getHours() + lIntval)
          break
          case 2 ://分
          date.setMinutes(date.getMinutes() + lIntval)
          break
          case 1 ://秒
          date.setSeconds(date.getSeconds() + lIntval)
          break;
          default:
             
          }
          return date.getYear() +'-' + (date.getMonth()+1) + '-' +date.getDate()+ ' '+ date.getHours()+':'+date.getMinutes()+':'+date.getSeconds()
          }

          posted on 2008-10-26 18:37 閱讀(1254) 評論(0)  編輯  收藏 所屬分類: 學習java

          公告

          希望有一天

          我能用鼠標雙擊我的錢包

          然后選中一張100元

          按住“ctrl+c”

          接著不停的“ctrl+v”

          嘻嘻~~~笑醒~~~



          導航

          <2008年10月>
          2829301234
          567891011
          12131415161718
          19202122232425
          2627282930311
          2345678

          統計

          常用鏈接

          留言簿(6)

          隨筆分類(102)

          隨筆檔案(398)

          文章分類

          文章檔案(10)

          有趣網絡

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 华坪县| 儋州市| 襄垣县| 彰化市| 房山区| 班玛县| 鹿邑县| 沙湾县| 建平县| 浮梁县| 石河子市| 赤壁市| 文昌市| 凌云县| 镇康县| 渭源县| 石河子市| 民勤县| 桐乡市| 宁陕县| 万山特区| 疏附县| 从江县| 屏山县| 马龙县| 山东省| 徐汇区| 芒康县| 高淳县| 息烽县| 洪洞县| 凉城县| 衡东县| 昌平区| 瑞金市| 泾川县| 富蕴县| 塘沽区| 榆树市| 玉林市| 吕梁市|