PDA

View Full Version : Any good javascripters out there?


Strygun
2007-08-20, 02:26 PM
Hey folks,

I've got a simple, easy JS clock that I'm trying to edit slightly. I need this script to be editable by timezone (in other words, I need to make it so I can control in which timezone the clock displays time.)

here's what I've got... do what you can!
<script type="text/javascript">
function createtime()
{
var time = new Date()
var hours = time.getHours()
var minutes = time.getMinutes()
var seconds = time.getSeconds()
var abbrev = "AM"
if (hours>=12)
abbrev="PM"
if (hours>12)
{
hours=hours-12
}
if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
var ctime=""+hours+":"+minutes+":"+seconds+" "+abbrev+""
if (document.all)
document.all.clock.innerHTML=ctime
else if (document.getElementById)
document.getElementById("clock").innerHTML=ctime
else
document.write(ctime) }
if (!document.all&&!document.getElementById)
createtime()
function loadtime()
{
if (document.all||document.getElementById)
setInterval("createtime()",1000)
}
</script>
<body onLoad="loadtime()">
<center><font size="1.5">London: <span id="clock"></span></font>