网站制作学习网ASP→正文:获取服务器时间2
字体:

获取服务器时间2

ASP 2008/1/16 8:03:10  点击:不统计

<html>

<head>

<script language=javascript type=text/javascript>

//特别注明:北京时间是格林尼治标准时加八小时,因此用的起始时间也是从八点起算的

var secondServer = <%=DateDiff(s, 1970-01-01 08:00:00, Now())%>;

var secondClient = parseInt(new Date().getTime()/1000);

var secondSub = secondServer - secondClient; //两端时间秒差

//星期函数

function initArray(){

this.length=initArray.arguments.length

for(var i=0;i<this.length;i++)

this[i+1]=initArray.arguments[i]

}

function meizzTime(n)

{

var mei = new Date();

mei.setTime(mei.getTime() + n*1000); //得到一个新的时间

var y = mei.getYear();//年

var t = mei.getMonth()+1;//月分需加1

var d = mei.getDate();//日

var w = new initArray(

星期日,

星期一,

星期二,

星期三,

星期四,

星期五,

星期六);

var z = w[mei.getDay()+1]//星期

var h = (mei.getHours() > 9) ? mei.getHours() : 0 + mei.getHours(); //时

var m = (mei.getMinutes() > 9) ? mei.getMinutes() : 0 + mei.getMinutes(); //分

var s = (mei.getSeconds() > 9) ? mei.getSeconds() : 0 + mei.getSeconds(); //秒

document.meizz.clock.value = y + 年 + t + 月 + d + 日 + z + + h +:+ m +:+ s; //显示年月日和时间

setTimeout(meizzTime(secondSub), 1000);

}

</script>

<meta http-equiv=’Content-Type’ content=’text/html; charset=gb2312’>

<meta http-equiv=refresh content=1000>

<title>javascript + asp 获取并实时显示服务器时间</title>

<style type=text/css>

<!--

body {

margin-left: 0px;

margin-top: 0px;

margin-right: 0px;

margin-bottom: 0px;

}

-->

</style>

<style type=text/css>

<!--

.form {

FONT-FAMILY:verdana,Arial, Helvetica;

FONT-SIZE: 9pt; color:#000000;

HEIGHT: 18px;

line-height:14px;

background:none;

border: none;

}

-->

</style>

</head>

<body onLoad=meizzTime(secondSub)>

<form name=meizz>

<input name=clock size=100 class=form>

</form>

</body>

</html>



·上一篇:获取服务器时间1 >>    ·下一篇:title换行 >>
推荐文章
最新文章