asp+|js| Server | display
The first type of code:
<script language=javascript type= "Text/javascript" >
Special note: Beijing time is Greenwich Standard PLUS eight hours, so the starting time is also starting from eight points
var secondserver = <%=datediff ("s", "1970-01-01 08:00:00", Now ())%>;
var secondclient = parseint (new Date (). GetTime ()/1000);
var secondsub = secondserver-secondclient; Both ends time seconds difference
function Meizztime (n)
{
var Mei = new Date ();
Mei.settime (Mei.gettime () + n*1000); To get a new time
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 = "" "+ 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 to obtain and real-time display server time </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>
<body >
<form name= "Meizz" >
<input name= "Clock" size= "class=" "Form" >
</form>
</body>
Another type of code:
<script language=javascript type= "Text/javascript" >
Special note: Beijing time is Greenwich Standard PLUS eight hours, so the starting time is also starting from eight points
var secondserver = <%=datediff ("s", "1970-01-01 08:00:00", Now ())%>;
var secondclient = parseint (new Date (). GetTime ()/1000);
var secondsub = secondserver-secondclient; Both ends time seconds difference
Week function
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); To get a new time
var y = mei.getyear ();//year
var t = mei.getmonth () +1;//need to add 1
var d = mei.getdate ();//day
var w = new Initarray (
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday");
var z = w[mei.getday () +1]//Week
var h = (Mei.gethours () > 9)? Mei.gethours (): "0" + mei.gethours (); When
var m = (Mei.getminutes () > 9)? Mei.getminutes (): "0" + mei.getminutes (); Part
var s = (Mei.getseconds () > 9)? Mei.getseconds (): "0" + mei.getseconds (); Seconds
Document.meizz.clock.value = y + "Year" + T + "month" + D + "Day" + z + "" + H + ":" + M + ":" + S; Show date and time
SetTimeout ("Meizztime (secondsub)", 1000);
}
</script>
<meta http-equiv= ' content-type ' content= ' text/html; charset=gb2312 ' >
<meta http-equiv= "Refresh" content= "1000" >
<title>javascript + ASP to obtain and real-time display server time </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>
<body >
<form name= "Meizz" >
<input name= "Clock" size= "class=" "Form" >
</form>
</body>
Because I do not have ASP space, so only everyone test themselves!