2008-01-25

Get time of different timezone

Dim theUTCTime As DateTime
    Dim localZone As TimeZone = TimeZone.CurrentTimeZone
    Dim TheZone As Integer = 1
    Const GMTZone As Integer = 1
    Const TOKZone As Integer = 2
    Const ATHZone As Integer = 3


    Private Sub Timer1_Tick( ByVal sender As System.Object, ByVal e As System.EventArgs)  Handles Timer1.Tick
        theUTCTime = localZone.ToUniversalTime(TimeString)
        Select Case TheZone
            Case GMTZone
                ‘ Greenwich Mean Time
                TimeBox.Text = theUTCTime.ToShortTimeString
            Case TOKZone
                ‘ Tokyo Time
                theUTCTime = theUTCTime.AddHours(9)
            Case ATHZone
                ‘ Athens Time
                theUTCTime = theUTCTime.AddHours(2)
        End Select
        TimeBox.Text = theUTCTime.ToShortTimeString
    End Sub

沒有留言:

張貼留言