Ext教程 arrow JavaScript技术 arrow 用Javascript进行周的计算(转载)
 
     
用Javascript进行周的计算(转载)
  2008-05-10
格式:<input>年<input>周,如:2004 年第 34周
输出:从哪年的哪月哪日至哪年的哪月哪日,如:2004年8月23日至2004年8月29日
年周值变,输出值也跟着变~  <style>
body{font-size:12px;background-color:#e5e5e5}
div{border: 1px solid #663300; background-color: #FCFCDA;padding:2px;font-size:12px;width:300px;text-align:center}
input{font-size:12px;border:1px outset;text-align:center;padding-top:2px}
.input2{font-size:12px;border:1px inset;text-align:center;padding-top:2px}
</style>
<script>
function countTime(Y,Z){
var d=new Date(Y,0,(7*Z))
var nd=new Date(d.getYear(),(d.getMonth()),(d.getDate()-d.getDay()+1))
Md=nd.getYear()+"-"+(nd.getMonth()+1)+"-"+nd.getDate() //一周的第一天

var nd=new Date(d.getYear(),(d.getMonth()),(d.getDate()-d.getDay()+7))
Sd=nd.getYear()+"-"+(nd.getMonth()+1)+"-"+nd.getDate() //一周的最后一天
Dis.innerHTML="<b>"+Y+"</b>年 第<b>"+Z+"</b>周 的日期输出:
"+Md+" 到 "+Sd
}
</script>
<center>
<fieldset style="width:330px"><legend>周的计算</legend>
<input type=text name=Ye class=input2 size=6 maxlength="4" onkeyup="countTime(Ye.value,Zs.value)"> 年 <input type=text name=Zs class=input2 size=6 maxlength="2" onkeyup="countTime(Ye.value,Zs.value)"> 周



<div id=Dis></div>


</fieldset>
</center>
< 上一篇   下一篇 >
   
 
 
 
Copyright Infotmation overhere. | designed by Magicbox from Mambochina
曼波整站系统 基于 Mambo 开发,是免费的自由软件,遵循 GNU/GPL 开源许可协议。
曼波整站系统5.4.0Mambo中国Mambo Resource 联合增强开发。  闽ICP备08005204号