浏览 3911 次
锁定老帖子 主题:获取服务器的时间
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2008-08-11
<script language="JavaScript" type="text/JavaScript"> var myday = ""; var mymonth = ""; var myweekday = ""; var year = ""; var myyear = ""; var weekday = ""; var http_request = ""; if(window.XMLHttpRequest){ try{http_request = new XMLHttpRequest();} catch (e){;} }else if(window.ActiveXObject){ try{ http_request = new ActiveXObject("Msxml2.XMLHTTP");} catch (e){ ; } if( http_request == null){ try { http_request = new ActiveXObject("Microsoft.XMLHTTP");} catch (e){;} } } http_request.open('HEAD', '.', false); http_request.send(null); var mydate = new Date(http_request.getResponseHeader('Date')); myweekday=mydate.getDay(); mymonth=mydate.getMonth()+1; myday= mydate.getDate(); myyear= mydate.getFullYear(); if(myweekday == 0) weekday=" 星期日 "; else if(myweekday == 1) weekday=" 星期一 "; else if(myweekday == 2) weekday=" 星期二 "; else if(myweekday == 3) weekday=" 星期三 "; else if(myweekday == 4) weekday=" 星期四 "; else if(myweekday == 5) weekday=" 星期五 "; else if(myweekday == 6) weekday=" 星期六 "; document.write(year+"年"+mymonth+"月"+myday+"日 "+weekday); </script> 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2008-08-13
获取服务器端的时间,怎么做到每一时刻都和服务器端时间同步?
不停的和服务器交互来获取? |
|
返回顶楼 | |