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

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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 五常市| 夏津县| 常德市| 娄烦县| 麦盖提县| 皮山县| 赣榆县| 尖扎县| 漳平市| 海阳市| 吴忠市| 孟津县| 磐安县| 大余县| 海安县| 蛟河市| 民和| 黔西县| 洱源县| 博罗县| 陆川县| 滕州市| 永清县| 改则县| 芦溪县| 甘肃省| 剑川县| 闵行区| 碌曲县| 浦东新区| 周至县| 乌兰浩特市| 松江区| 东兰县| 稻城县| 芦山县| 普陀区| 伊春市| 西平县| 武陟县| 广昌县|