我要计算距离奥运还有多少天,用javascript怎么弄?
解决方案 »
- 【急】Repeater嵌套 限定显示记录数问题
- ASP.net 邮件问题
- 在Ext控件里能不能实现asp里的CheckBoxList控件功能?
- 30分:AJAX 中UpdatePanel的一个问题!(最好是理论辅助实际代码解决问题,)O(∩_∩)O谢谢
- webpart 急
- detailsview 下拉联动
- 如果我的DataGrid中超链接字段,需要传递两个参数,那么URL字段我怎么输入?
- 新手问题_为什么要学ASP.net
- 请问一下IIS6里的“../"父目录不能用了,怎么改呢
- 如何获得DATAGRID里INPUT里的值(或是属性)呢?
- FileUpload控件如何设置点浏览时弹出的选择文件窗口为图片类型(默认为所有类型)
- Asp.net视频播放问题..在线等..急..提意见者有分....
birthday="2008-08-08"
msgbox(datediff("d",now,cdate(birthday)))
</script>
intDate = today.getDate();//返回当前的天日期
intHours = today.getHours();//返回当前小时
intMinutes = today.getMinutes();//分钟
intSeconds = today.getSeconds();//秒
intMonth = today.getMonth()+1 ;//月加1
intYear = today.getYear();//返回年
<script language=JavaScript>
var tt="<%# etime(DataBinder.Eval(Container.DataItem,"etime").ToString().Trim())%>";
DateTime = new Array();
DateTime = tt.split("-");
var year = DateTime[0];
var month = DateTime[1];
var day = DateTime[2];
var hour = DateTime[3];
var minitue = DateTime[4];
var second = DateTime[5];
var Time = new Date(year,month - 1,day,hour,minitue,second);
var auctionDate = -15314325;
var startTime = (new Date("2009/1/2")).getTime();
var Temp;
var timerID = null;
var timerRunning = false;
function showtime(){
now = new Date();
var ts=parseInt((Time.getTime()-now.getTime())/1000)+auctionDate;
var dateLeft = 0;
var hourLeft = 0;
var minuteLeft = 0;
var secondLeft = 0;
if(ts < 0){
ts = 0;
CurHour = 0;
CurMinute = 0;
CurSecond = 0;}
else {
dateLeft =parseInt(ts/86400);
ts = ts - dateLeft * 86400;
hourLeft = parseInt(ts/3600);
ts = ts - hourLeft * 3600;
minuteLeft = parseInt(ts/60);
secondLeft = ts - minuteLeft * 60;}
if(hourLeft < 10) hourLeft = '0' +hourLeft;
if(minuteLeft < 10) minuteLeft = '0' +minuteLeft;
if(secondLeft<10) secondLeft='0'+secondLeft;
if( dateLeft > 0 )
dateLeft = dateLeft + "天" ;
else
dateLeft = "";
if( hourLeft > 0 )
hourLeft = hourLeft + "小时" ;
else{
if( dateLeft != "" )
hourLeft = "00小时";
else
hourLeft = "";}
if( minuteLeft > 0 )
minuteLeft = minuteLeft + "分钟" ;
else{
if( dateLeft !="" || hourLeft != "")
minuteLeft = "00分钟";
else
minuteLeft = "";}
if( secondLeft > 0 )
secondLeft = secondLeft + "秒" ;
else{
if( dateLeft !="" || hourLeft != "" || minuteLeft != "")
secondLeft = "00秒";
else
secondLeft = "";}
//if (dateLeft == '') {
Temp=dateLeft+hourLeft+minuteLeft+secondLeft ;
//}else {
//Temp=dateLeft+hourLeft;}
if(dateLeft <=0 && hourLeft<=0 && minuteLeft<=0 && secondLeft <=0){
Temp = "结束";
stopclock();}
if (document.getElementById('time')) document.getElementById('time').value=Temp;
timerID = setTimeout("showtime()",1000);
timerRunning = true;}
var timerID = null;
var timerRunning = false;
function stopclock(){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;}
function macauclock(){
stopclock();
showtime();}
function onloadall(){
macauclock();
try{
initprovcity(); }
catch(e){
}}
try{
onload=onloadall();}
catch(e){}
</script>
function DateDiff(interval,date1,date2){
var long = date2.getTime() - date1.getTime(); //相差毫秒
switch(interval.toLowerCase()){
case "y": return parseInt(date2.getFullYear() - date1.getFullYear());
case "m": return parseInt((date2.getFullYear() - date1.getFullYear())*12 + (date2.getMonth()-date1.getMonth()));
case "d": return parseInt(long/1000/60/60/24);
case "w": return parseInt(long/1000/60/60/24/7);
case "h": return parseInt(long/1000/60/60);
case "n": return parseInt(long/1000/60);
case "s": return parseInt(long/1000);
case "l": return parseInt(long);
}
}
alert(DateDiff("d",new Date(),new Date(2008,8,8)));
</script>
:)
alert("距离奥运还有"+ " <%=(new DateTime(2008, 8, 8) - DateTime.Now).Days%>" + "天");
intDate = today.getDate();//返回当前的天日期
intHours = today.getHours();//返回当前小时
intMinutes = today.getMinutes();//分钟
intSeconds = today.getSeconds();//秒
intMonth = today.getMonth()+1 ;//月加1
intYear = today.getYear();//返回年