i have this javascript code:
<div id="page-top">
<div id="topbar">
<table>
<td bgcolor="#8BC5FF" height="40" width="40">
<img src="../images/clock/dg8.gif" name="hr1"><img
src="../images/clock/dg8.gif" name="hr2"><img
src="../images/clock/dgc.gif" name="c"><img
src="../images/clock/dg8.gif" name="mn1"><img
src="../images/clock/dg8.gif" name="mn2"><img
src="../images/clock/dgc.gif" name="c"><img
src="../images/clock/dg8.gif" name="se1"><img
src="../images/clock/dg8.gif" name="se2"&g开发者_如何学Pythont;<img
src="../images/clock/dgpm.gif" name="ampm">
</td></table>
<script language="javascript">
dg0 = new Image();dg0.src = "../images/clock/dg0.gif";
dg1 = new Image();dg1.src = "../images/clock/dg1.gif";
dg2 = new Image();dg2.src = "../images/clock/dg2.gif";
dg3 = new Image();dg3.src = "../images/clock/dg3.gif";
dg4 = new Image();dg4.src = "../images/clock/dg4.gif";
dg5 = new Image();dg5.src = "../images/clock/dg5.gif";
dg6 = new Image();dg6.src = "../images/clock/dg6.gif";
dg7 = new Image();dg7.src = "../images/clock/dg7.gif";
dg8 = new Image();dg8.src = "../images/clock/dg8.gif";
dg9 = new Image();dg9.src = "../images/clock/dg9.gif";
dgam= new Image();dgam.src= "../images/clock/dgam.gif";
dgpm= new Image();dgpm.src= "../images/clock/dgpm.gif";
dgc = new Image();dgc.src = "../images/clock/dgc.gif";
function dotime(){
theTime=setTimeout('dotime()',1000);
d = new Date();
hr= d.getHours()+100;
mn= d.getMinutes()+100;
se= d.getSeconds()+100;
if(hr==100){hr=112;am_pm='am';}
else if(hr<112){am_pm='am';}
else if(hr==112){am_pm='pm';}
else if(hr>112){am_pm='pm';hr=(hr-12);}
tot=''+hr+mn+se;
document.hr1.src = '../images/clock/dg'+tot.substring(1,2)+'.gif';
document.hr2.src = '../images/clock/dg'+tot.substring(2,3)+'.gif';
document.mn1.src = '../images/clock/dg'+tot.substring(4,5)+'.gif';
document.mn2.src = '../images/clock/dg'+tot.substring(5,6)+'.gif';
document.se1.src = '../images/clock/dg'+tot.substring(7,8)+'.gif';
document.se2.src = '../images/clock/dg'+tot.substring(8,9)+'.gif';
document.ampm.src= '../images/clock/dg'+am_pm+'.gif';}
dotime();
</script>
</div>
</div>
this code allow the user to see a Digital clock, its work good, put the problem that i want to use this clock with my current timezone (EET) not the user timezone. (the timezone of the server, not to the client). how can i do this
Here:
d = new Date();
you need to inject the server time:
d = new Date(<%=year%>, <%=month%>, <%=day%>, <%=hours%>, <%=minutes%>, <%=seconds%>, <%=milliseconds%>);
where obviously those are server side variables representing the server time and you should adapt the syntax based on the server side language you are using.
Here are the different overloads of the Date
constructor you could use to assign it to some given date.
精彩评论