'How to display the current time continously in a different time zone?

I would like to display the current time continuously but in a different time zone?

The following code will display the current time continuously.

Can I update to get the time in a different time zone.?

<script type="text/javascript">
    function ShowTime() {
        var dt = new Date();
        document.getElementById("<%= TextBox1.ClientID %>").value
        = dt.toLocaleTimeString();
        window.setTimeout("ShowTime()", 1000);
    }
</script>
<asp:TextBox ID="TextBox1" runat="server" CssClass="time"></asp:TextBox>

<script type="text/javascript">
    // a startup script to put everything in motion
    window.setTimeout("ShowTime()", 1000);
</script>

Please help
Thank you
Joe



Solution 1:[1]

This article talks about how to calculate time in another timezone:

https://web.archive.org/web/1/http://articles.techrepublic%2ecom%2ecom/5100-10878_11-6016329.html

Solution 2:[2]

The datejs library might be a good starting point. There's a getTimezoneOffset method that gives you the time offset for a given timezone.

Also, consider using setInterval instead of setTimeout.

Solution 3:[3]

Convert date to timestamp and add the hours for the preffered timezone.

Convert tmestamp to date again.

var currentdate = 20101007163045

current timestamp= time(currentdate);

another timezone + 3 hours var expectedtimestamp=timestamp + time(3hrs)

expecteddate= date(expectedtimestamp).

This is algorithm. check your syntaxes

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community
Solution 2 Ondrej Tucny
Solution 3 zod