龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > Javascript编程 >

javascript怎么获取服务器端日期时间代码

时间:2012-12-29 08:41来源:未知 作者:admin 点击:
分享到:
javascript怎么获取服务器端日期时间代码 有需要的朋友可参考一下。 代码如下 var DD,MM,YY,hh,mm; if(document.all){ window.XMLHttpRequest=function(){ var get=['Microsoft.XMLHTTP','Msxml2.XMLHTTP']; for(var i=0;iget.l
javascript怎么获取服务器端日期时间代码 有需要的朋友可参考一下。
 代码如下

var DD,MM,YY,hh,mm;
if(document.all){
     window.XMLHttpRequest=function(){
         var get=['Microsoft.XMLHTTP','Msxml2.XMLHTTP'];
   for(var i=0;i<get.length;i++){try{return new ActiveXObject(get[i])}catch(e){}};
     };
 }
window.time=new Date();
targetTime=new Date();
function webDate(fn){
  var Htime=new XMLHttpRequest();
  Htime.onreadystatechange=function(){Htime.readyState==4&&(fn(new Date(Htime.getResponseHeader('Date'))))};
  Htime.open('HEAD', '/?_='+(-new Date));
  Htime.send(null);
 }
webDate(function (webTime){
   DD=webTime.getDate(),MM=webTime.getMonth()+1,YY=webTime.getFullYear(),hh=webTime.getHours();mm=webTime.getMinutes();
})

alert(YY+" "+MM+DD+" "+hh+mm)


精彩图集

赞助商链接