随笔-20  评论-3  文章-9  trackbacks-0
客户端时间: 
<b><font color=#FF0000>:10-15-2009 20:10:23:</font></b><span id="span_dt_dt"></span>  
            <font color="#FF0000">  
            <SCRIPT language=javascript>  
            <!--  
            function show_date_time(){  
            window.setTimeout("show_date_time()", 1000);  
            BirthDay=new Date("10-15-2009 20:10:23");//  
            today=new Date();  
            timeold=(BirthDay.getTime()-today.getTime());  
            sectimeold=timeold/1000  
            secondsold=Math.floor(sectimeold);  
            msPerDay=24*60*60*1000  
            e_daysold=timeold/msPerDay  
            daysold=Math.floor(e_daysold);  
            e_hrsold=(e_daysold-daysold)*24;  
            hrsold=Math.floor(e_hrsold);  
            e_minsold=(e_hrsold-hrsold)*60;  
            minsold=Math.floor((e_hrsold-hrsold)*60);  
            seconds=Math.floor((e_minsold-minsold)*60);  
            span_dt_dt.innerHTML="<b><font color=00CC00>"+daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒"+"</b><br></font>" ;  
            }  
            show_date_time();  
            //-->  
            </SCRIPT>  
            </font>  
取服务器时间:
<span id=serverTime>正在同步...</span>
<script>
var dayNames = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
xmlhttp.open("HEAD", "http://www.zzedu.net.cn", false);
xmlhttp.setRequestHeader("Range", "bytes=-1");
xmlhttp.send();
var tts =new Date(xmlhttp.getResponseHeader("Date"));
serverTime.innerHTML="<span style=color:red>" + tts.getYear()+"."+(tts.getMonth()+ 1)+"."+tts.getDate()+"</span><br><span style=color:blue>"+tts.getHours()+":"+tts.getMinutes()+":"+tts.getSeconds()+"</span><br><span style=color:yellow>"+ dayNames[tts.getDay()] +"";
setInterval("tts.setSeconds(tts.getSeconds()+1);serverTime.innerHTML='<span style=color:red>' + tts.getYear()+'.'+(tts.getMonth()+ 1)+'.'+tts.getDate()+'</span><br><span style=color:blue>'+tts.getHours()+':'+tts.getMinutes()+':'+tts.getSeconds()+'</span><br><span style=color:yellow>'+ dayNames[tts.getDay()] +'</span>';",1000);
</script>
posted on 2009-03-11 14:43 蓝山 阅读(246) 评论(0)  编辑  收藏 所属分类: JavaScript

只有注册用户登录后才能发表评论。


网站导航: