For Programmers: Free Programming Magazines  


Home > Archive > C# > January 2005 > Dynamic World Clock









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Dynamic World Clock
Eric1776

2005-01-11, 3:59 pm

I wasn't sure if I should put this is a JavaScript issue or .NET issue.

Anyway, I have some javascript that shows time zones on the page. By
default, it wants to use the machines local time. We want it to use the
server time. So I'm assuming that we need some kind of server code to
do this.

So I put in a line of .NET that tells it the current server time. This
works except that the time no longer refreshes on its own like it did
before. I have to refresh the page to get the most current time.

Here is some of the code.

function GetTime()

{

var zuluTimeJS = "<% Response.Write(DateTime.UtcNow.ToString("ddd MMM
dd H:mm:ss 'GMT' yyyy")); %>";

var dt = new Date(zuluTimeJS);

var def = dt.getTimezoneOffset()/60;

var gmt = (dt.getHours() + def);

var ending = ":" + IfZero(dt.getMinutes());

var _GMT =check24(((gmt) > 24) ? ((gmt) - 24) : (gmt));

document.clock._GMT.value = (IfZero(_GMT) + ":" +
IfZero(dt.getMinutes()));

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com