当前位置:首页
开发技术指南» 文章正文
    引言:

 ·求一正则表达式    »显示摘要«
    摘要: 有一字符串 $content = <div id="memberflat" class="titlebar"> <div class="drawsidetow">会员平台</div> <div class="smalltitle">为何注册?</div&......
 ·关于sleep函数,初学者    »显示摘要«
    摘要: 我用vc编译c程序,里面用到了sleep函数,请问这个函数在哪个lib库文件里面呢。 #include <stdlib.h> #include <stdio.h> int main() { printf("this is a hello test under cygwin!\n"); sleep(2); printf("wa......


怎么用JS来实现一个日期型数值加上月份数/天数得到另外一个日期型数值呢有没有这样的函数

如题,谢谢

NO.1   作者: matrixy

Date对象的构造方法就行....  
   
  new   Date(year,month,day,hours,minutes,seconds,milseconds)  
   
  各个参数,你可以随便的怎么样传入数值型参数,Date对象会自己帮你计算好日期...  
   
  var   dat   =   new   Date();  
  new   Date(dat.getFullYear()-1,dat.getMonth(),dat.getDate());  
  获得去年的今天这一天的日期...

NO.2   作者: JK_10000

<script   >  
  Date.prototype.addDay=function   (num)  
  {  
  this.setDate(this.getDate()+num);  
  return   this;  
  }  
   
  Date.prototype.addMonth=function   (num)  
  {  
  var   tempDate=this.getDate();  
  this.setMonth(this.getMonth()+num);  
  if(tempDate!=this.getDate())   this.setDate(0);  
  return   this;  
  }  
   
  Date.prototype.addYear=function   (num)  
  {  
  var   tempDate=this.getDate();  
  this.setYear(this.getYear()+num);  
  if(tempDate!=this.getDate())   this.setDate(0);  
  return   this;  
  }  
   
   
  var   d1;  
  d1=new   Date(2004/02/29);  
  alert(d1.addYear(1));  
   
  d1=new   Date(2004/01/31);  
  alert(d1.addMonth(1));  
   
  d1=new   Date(2004/02/29);  
  alert(d1.addDay(1));  
   
   
  </script>


    摘要: 我使用如下语句在oncreate中动态创建了一个树型控件 if (!m_wndtree.create(ws_child|ws_visible|tvs_haslines|tvs_hasbuttons|tvs_linesatroot, crect(0, 0, 0, 0), &m_wndmybar1, 100)) { trace0("failed to create in......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE