posts - 101,  comments - 29,  trackbacks - 0

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

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

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

           


          格式轉(zhuǎn)換

          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 閱讀(41186) 評論(3)  編輯  收藏

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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 保德县| 酒泉市| 无极县| 宁德市| 永定县| 象州县| 林西县| 航空| 南京市| 樟树市| 三江| 郎溪县| 永州市| 二连浩特市| 宜君县| 桃园县| 临潭县| 高阳县| 东台市| 镶黄旗| 铅山县| 杭锦后旗| 乌兰浩特市| 南平市| 中阳县| 瑞丽市| 阳谷县| 西林县| 巢湖市| 韩城市| 上高县| 洛南县| 海林市| 开阳县| 杭锦后旗| 马山县| 易门县| 突泉县| 九龙坡区| 富蕴县| 杭州市|