rainemaida
11-18-2005, 05:06 AM
Ok, I have to have a code on my site that gets the time off of my server. My server is located elsewhere and i have no control over it. However the system time for the server is a few minutes fast, which is quite important. I would like to know how to change my code to get the system date and then take two minutes off.. I have done this already however my real problem is when it goes to on the hour or a minute past and therefore it'll say -2 minutes. Can somebody please help, here is my code.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Current Server Time</title>
</head>
<body>
<script type="text/javascript">
// Current Server Time script (SSI or PHP)- By JavaScriptKit.com (http://www.javascriptkit.com)
// For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/
// This notice must stay intact for use.
//Depending on whether your page supports SSI (.shtml) or PHP (.php), UNCOMMENT the line below
your page supports and COMMENT the one it does not:
//Default is that SSI method is uncommented, and PHP is commented:
//var currenttime = '<!--#config timefmt="%B %d, %Y %H:%M:%S"--><!--#echo var="DATE_LOCAL" -->'
//SSI method of getting server date
var currenttime = '<? print date("F d, Y H:i:s", time())?>' //PHP method of getting server date
///////////Stop editting here/////////////////////////////////
var montharray=new
Array("January","February","March","April","May","June","July","August","September","October","No
vember","December")
var serverdate=new Date(currenttime)
function padlength(what){
var output=(what.toString().length==1)? "0"+what : what
return output
}
function displaytime(){
serverdate.setSeconds(serverdate.getSeconds()+1)
var datestring=montharray[serverdate.getMonth()]+" "+padlength(serverdate.getDate())+",
"+serverdate.getFullYear()
var
timestring=padlength(serverdate.getHours())+":"+padlength(serverdate.getMinutes()-2)+":"+padlengt
h(serverdate.getSeconds())
document.getElementById("servertime").innerHTML=datestring+" "+timestring
}
window.onload=function(){
setInterval("displaytime()", 1000)
}
</script>
<p align="center"><font size="2"><span id="servertime"></span></p>
</body>
</html>
Thank you
Steven
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Current Server Time</title>
</head>
<body>
<script type="text/javascript">
// Current Server Time script (SSI or PHP)- By JavaScriptKit.com (http://www.javascriptkit.com)
// For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/
// This notice must stay intact for use.
//Depending on whether your page supports SSI (.shtml) or PHP (.php), UNCOMMENT the line below
your page supports and COMMENT the one it does not:
//Default is that SSI method is uncommented, and PHP is commented:
//var currenttime = '<!--#config timefmt="%B %d, %Y %H:%M:%S"--><!--#echo var="DATE_LOCAL" -->'
//SSI method of getting server date
var currenttime = '<? print date("F d, Y H:i:s", time())?>' //PHP method of getting server date
///////////Stop editting here/////////////////////////////////
var montharray=new
Array("January","February","March","April","May","June","July","August","September","October","No
vember","December")
var serverdate=new Date(currenttime)
function padlength(what){
var output=(what.toString().length==1)? "0"+what : what
return output
}
function displaytime(){
serverdate.setSeconds(serverdate.getSeconds()+1)
var datestring=montharray[serverdate.getMonth()]+" "+padlength(serverdate.getDate())+",
"+serverdate.getFullYear()
var
timestring=padlength(serverdate.getHours())+":"+padlength(serverdate.getMinutes()-2)+":"+padlengt
h(serverdate.getSeconds())
document.getElementById("servertime").innerHTML=datestring+" "+timestring
}
window.onload=function(){
setInterval("displaytime()", 1000)
}
</script>
<p align="center"><font size="2"><span id="servertime"></span></p>
</body>
</html>
Thank you
Steven