posts - 101,  comments - 29,  trackbacks - 0

          常用鏈接

          留言簿

          隨筆檔案(101)

          我的連接

          搜索

          •  

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          一。時(shí)間加減,日期加減,年月日加減一樣。

          var   mydate=   new   Date('2012-05-10 10:10:21'); 
           mydate.setDate(mydate.getDate()+50);  //當(dāng)前時(shí)間加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) 評(píng)論(3)  編輯  收藏

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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 临沂市| 安阳市| 丹江口市| 武城县| 新巴尔虎左旗| 井研县| 泊头市| 电白县| 屏东市| 林甸县| 洪雅县| 屏山县| 县级市| 乌兰浩特市| 湖北省| 江门市| 新泰市| 广宁县| 松原市| 成安县| 开远市| 常德市| 高淳县| 手机| 贵港市| 蒙城县| 澳门| 新郑市| 漠河县| 长白| 宝应县| 兰坪| 石狮市| 开江县| 彭阳县| 邢台县| 康保县| 西青区| 修文县| 博湖县| 寻甸|