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 閱讀(41190) 評(píng)論(3)  編輯  收藏

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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 同江市| 芜湖市| 蕉岭县| 浙江省| 肃宁县| 石家庄市| 稻城县| 华亭县| 龙川县| 天柱县| 通海县| 民乐县| 博野县| 宁安市| 铁力市| 宁河县| 河南省| 阿尔山市| 新巴尔虎左旗| 双牌县| 封丘县| 丰城市| 宝坻区| 红原县| 兴安盟| 马关县| 龙游县| 怀安县| 濮阳市| 白沙| 会同县| 镇沅| 当涂县| 喀什市| 赣榆县| 开平市| 维西| 乌海市| 漳浦县| 高安市| 上虞市|