javascript方法动态显示前一天与后一天日期时间
2007-07-06 21:05
761 查看
脚本语言:
放入客户端代码后
<SCRIPT LANGUAGE="JavaScript">
<!--
//alert('<%=ntime%>')
var now = new Date();
n0=now.getYear()
y0=now.getMonth()+1
d0=now.getDate()
h0="0"+now.getHours();
m0="0"+now.getMinutes();
s0="0"+now.getSeconds();
if(h0>9){h0=now.getHours()}
if(m0>9){m0=now.getMinutes()}
if(s0>9){s0=now.getSeconds()}
document.all.tb1.value = n0+"-"+y0+"-"+d0+" "+h0+":"+m0+":"+s0
DaysToAdd=0;
function predata_Click()
{
DaysToAdd=DaysToAdd-1;
var newdate=new Date(n0,y0,d0,h0,m0,s0);
var newtimems=newdate.getTime()+(DaysToAdd*24*60*60*1000);
newdate.setTime(newtimems);
var xdate=newdate
var newh="0"+xdate.getHours()
var newm="0"+xdate.getMinutes()
var news="0"+xdate.getSeconds()
if(newh>9){newh=xdate.getHours()}
if(newm>9){newm=xdate.getMinutes()}
if(news>9){news=xdate.getSeconds()}
document.form.tb1.value=xdate.getYear()+"-"+xdate.getMonth()+"-"+xdate.getDate()+" "+newh+":"+newm+":"+news
frame2.src="./search/yuliangmview.asp"
}
function passdata_Click()
{
DaysToAdd=DaysToAdd+1;
var newdate=new Date(n0,y0,d0,h0,m0,s0);
var newtimems=newdate.getTime()+(DaysToAdd*24*60*60*1000);
newdate.setTime(newtimems);
var xdate=newdate
var newh="0"+xdate.getHours()
var newm="0"+xdate.getMinutes()
var news="0"+xdate.getSeconds()
if(newh>9){newh=xdate.getHours()}
if(newm>9){newm=xdate.getMinutes()}
if(news>9){news=xdate.getSeconds()}
document.form.tb1.value=xdate.getYear()+"-"+xdate.getMonth()+"-"+xdate.getDate()+" "+newh+":"+newm+":"+news
frame2.src="./search/yuliangmview.asp"
}
//-->
</SCRIPT>
控件代码:
<form name="form" method="post">
<table width="100%">
<tr><td align=center>
<!-- onclick="callpreviousDay()"onclick="callnextDay()" -->
<input type="button" name="predata" value="前一天" style="width: 57px;
height: 20px" OnClick="predata_Click()" >
<input id="tb1" type="text" ReadOnly="True" style="width: 140px;
height: 20px;text-align: center;" onclick='showCal()' />
<input type="button" name="passdata" value="后一天" style="width: 57px;
height: 20px" OnClick="passdata_Click()" >
</tr>
</table>
</form>
放入客户端代码后
<SCRIPT LANGUAGE="JavaScript">
<!--
//alert('<%=ntime%>')
var now = new Date();
n0=now.getYear()
y0=now.getMonth()+1
d0=now.getDate()
h0="0"+now.getHours();
m0="0"+now.getMinutes();
s0="0"+now.getSeconds();
if(h0>9){h0=now.getHours()}
if(m0>9){m0=now.getMinutes()}
if(s0>9){s0=now.getSeconds()}
document.all.tb1.value = n0+"-"+y0+"-"+d0+" "+h0+":"+m0+":"+s0
DaysToAdd=0;
function predata_Click()
{
DaysToAdd=DaysToAdd-1;
var newdate=new Date(n0,y0,d0,h0,m0,s0);
var newtimems=newdate.getTime()+(DaysToAdd*24*60*60*1000);
newdate.setTime(newtimems);
var xdate=newdate
var newh="0"+xdate.getHours()
var newm="0"+xdate.getMinutes()
var news="0"+xdate.getSeconds()
if(newh>9){newh=xdate.getHours()}
if(newm>9){newm=xdate.getMinutes()}
if(news>9){news=xdate.getSeconds()}
document.form.tb1.value=xdate.getYear()+"-"+xdate.getMonth()+"-"+xdate.getDate()+" "+newh+":"+newm+":"+news
frame2.src="./search/yuliangmview.asp"
}
function passdata_Click()
{
DaysToAdd=DaysToAdd+1;
var newdate=new Date(n0,y0,d0,h0,m0,s0);
var newtimems=newdate.getTime()+(DaysToAdd*24*60*60*1000);
newdate.setTime(newtimems);
var xdate=newdate
var newh="0"+xdate.getHours()
var newm="0"+xdate.getMinutes()
var news="0"+xdate.getSeconds()
if(newh>9){newh=xdate.getHours()}
if(newm>9){newm=xdate.getMinutes()}
if(news>9){news=xdate.getSeconds()}
document.form.tb1.value=xdate.getYear()+"-"+xdate.getMonth()+"-"+xdate.getDate()+" "+newh+":"+newm+":"+news
frame2.src="./search/yuliangmview.asp"
}
//-->
</SCRIPT>
控件代码:
<form name="form" method="post">
<table width="100%">
<tr><td align=center>
<!-- onclick="callpreviousDay()"onclick="callnextDay()" -->
<input type="button" name="predata" value="前一天" style="width: 57px;
height: 20px" OnClick="predata_Click()" >
<input id="tb1" type="text" ReadOnly="True" style="width: 140px;
height: 20px;text-align: center;" onclick='showCal()' />
<input type="button" name="passdata" value="后一天" style="width: 57px;
height: 20px" OnClick="passdata_Click()" >
</tr>
</table>
</form>
相关文章推荐
- javascript实现日期时间动态显示
- javascript实现日期时间动态显示示例代码
- javascript显示动态时间的方法汇总
- JS实现日期时间动态显示的方法
- javascript实现日期时间动态显示
- javascript动态显示日期时间
- 记录下:在html中利用JavaScript动态的显示日期和时间
- 动态显示日期时间(javascript时钟)
- JavaScript实现同步于本地时间的动态时间显示方法
- JavaScript实现同步于本地时间的动态时间显示方法
- JavaScript代码:在网页中动态显示当前日期和时间
- mysql 获取当前日期,前一天,后一天方法及时间格式化 wordpress 后台头部添加气泡通知
- JavaScript在浏览器标题栏上显示当前日期和时间的方法
- 动态显示日期时间(javascript时钟)
- JavaScript-获取固定格式日期(2016-05-22)以及"连续"获取前一天、后一天的方法总结
- 一个简洁的(javascript时钟)动态显示日期时间
- javascript 动态显示日期时间的脚本收集
- javascript实现日期时间动态显示
- javascript动态显示日期、星期、时间
- javascript实现日期时间动态显示示例代码