Ok this is like the dumbest, yet strangest thing (to me anyway)... So I have the following script in an HTML file:
<script language="JavaScript">
<!--
document.write("<span id='clock'></span>");
var now,hours,minutes,timeValue;
function showtime(){
now = new Date();
hours = now.getUTCHours();
hours -= 2
if (hours>=24)
{
hours-=24
}
minutes = now.getUTCMinutes();
timeValue = hours + " :";
timeValue += ((minutes < 10) ? " 0" : " ") + minutes;
clock.innerHTML = timeValue;
setTimeout("showtime()",100);
}
showtime();
//-->
</script>
Ok, no big deal... Then I realized that sometimes when I travel to regions with GMT being a negative value, the clock could be showing a negative number sometimes, so I tried to fix it by inserting another IF statement, no go... Elseif, no go... The clock wouldn't show at all. What am I doing wrong?
<script language="JavaScript">
<!--
document.write("<span id='clock'></span>");
var now,hours,minutes,timeValue;
function showtime(){
now = new Date();
hours = now.getUTCHours();
hours -= 2
if (hours>=24)
{
hours-=24
}
minutes = now.getUTCMinutes();
timeValue = hours + " :";
timeValue += ((minutes < 10) ? " 0" : " ") + minutes;
clock.innerHTML = timeValue;
setTimeout("showtime()",100);
}
showtime();
//-->
</script>
Ok, no big deal... Then I realized that sometimes when I travel to regions with GMT being a negative value, the clock could be showing a negative number sometimes, so I tried to fix it by inserting another IF statement, no go... Elseif, no go... The clock wouldn't show at all. What am I doing wrong?