posts - 101,  comments - 29,  trackbacks - 0

          一。時間加減,日期加減,年月日加減一樣。

          var   mydate=   new   Date('2012-05-10 10:10:21'); 
           mydate.setDate(mydate.getDate()+50);  //當前時間加50天

          二。分鐘秒鐘加減,setMinutes方法

           


          格式轉換

          Date.prototype.format = function(format)
          {
          var o = {
                      "M+" : this.getMonth()+1, //month
                      "d+" : this.getDate(), //day
                      "h+" : this.getHours(), //hour
                      "m+" : this.getMinutes(), //minute
                      "s+" : this.getSeconds(), //second
                      "q+" : Math.floor((this.getMonth()+3)/3), //quarter
                      "S" : this.getMilliseconds() //millisecond
                  }
              if(/(y+)/.test(format))
              format=format.replace(RegExp.$1,(this.getFullYear()+"").substr(4 - RegExp.$1.length));
              for(var k in o)
              if(new RegExp("("+ k +")").test(format))
              format = format.replace(RegExp.$1,RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));
              return format;
          }

           


           

          var   mydate=   new   Date('2012-05-10 10:10:21'); 
                    mydate.setDate(mydate.getDate()+50);
                    mydate.setMinutes(min, sec, ms)
                    alert(mydate.format("yyyy-MM-dd hh:mm:ss"));



          posted on 2012-05-10 22:43 mixer-a 閱讀(41192) 評論(3)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 日照市| 宣威市| 青神县| 石河子市| 视频| 巴青县| 漠河县| 都匀市| 石家庄市| 嘉鱼县| 崇信县| 江西省| 尤溪县| 合山市| 岚皋县| 米林县| 马龙县| 新密市| 上栗县| 邮箱| 岚皋县| 固始县| 岳阳县| 杭锦后旗| 榆社县| 思南县| 太和县| 都安| 许昌市| 收藏| 建阳市| 库尔勒市| 蒙自县| 阜平县| 卢氏县| 柳江县| 麻栗坡县| 漾濞| 新河县| 巴里| 乌海市|