PDA

View Full Version : Web Server Time and Date Script



simonf
12-23-2004, 07:57 PM
Hi DDAdmin

A simple script that seems to work, so that a web site can display the time and date off their own server by TimeZone etc. rgds,Simonf :cool:

<FORM name=WSTC><INPUT size=63 name=WSClock></P></FORM>
<SCRIPT language=javascript>
// Web Server Time Script (Designed by simon.fish@cherrycreektrading.co.za)
// Last updated: 12/23/2004
// Designed to show your users the time and date on your server
// this example is set to US central time, to modify change the getUTCHours()-6 parameter to reflect your timezome from GMT (i.e 0=GMT)
// Permission granted and modified by Dynamicdrive.com to include script in archive
function show()
{
var Cdate=new Date()
var day=Cdate.getUTCDate()
var month=Cdate.getUTCMonth()+1
var year=Cdate.getUTCFullYear()
var hours=Cdate.getUTCHours()-6
var minutes=Cdate.getUTCMinutes()
var seconds=Cdate.getUTCSeconds()
if (hours<=9)
hours="0"+hours
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
document.WSTC.WSClock.value="U.S Central Time is now: "+hours+":"+minutes+":"+seconds+" and the current date is "+month+"/"+day+"/"+year

setTimeout("show()",1000)
}
show()
//-->
</SCRIPT>