+ Reply to Thread
Results 1 to 4 of 4

Running Clock in Excel with different Time Zone

Hybrid View

  1. #1
    Registered User
    Join Date
    11-28-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    3

    Smile Running Clock in Excel with different Time Zone

    Need running clock in Excel... in A1 I have put running clock which is taking current system time. However, I want to add running clocks for EST in B1 - CST in C1 and PST in D1. Any help much appreciated.

    Atatching excel... if anyone can update in same and attach back, will be very thankful.

    VB code I used to display current system running clock

    Global clockOn As Boolean
    Sub runClock()
    Range("A1").Value = Now()
    If clockOn = True Then
    Application.OnTime Now + TimeValue("00:00:01"), "runClock"
    End If
    End Sub
    Sub startClock()
    clockOn = True
    runClock
    End Sub
    Sub stopClock()
    clockOn = False

    End Sub
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Running Clock in Excel with different Time Zone

    Hi - here is a link to describe how to get the timezone, from there you can offset as neccessary to the different zones:
    http://www.cpearson.com/excel/TimeZo...lightTime.aspx

  3. #3
    Registered User
    Join Date
    11-28-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Running Clock in Excel with different Time Zone

    Gone through that link but litlle confused. Not that much familier with the codes

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Running Clock in Excel with different Time Zone

    http://www.mrexcel.com/forum/excel-q...time-zone.html

    Is that link any more help? Looking at post #5 put the code at the bottom in a module and then use:
    sub macro_1
    msgbox GetTimeZone()
    end sub
    Option Explicit
    
        
        Private Type SYSTEMTIME
            wYear As Integer
            wMonth As Integer
            wDayOfWeek As Integer
            wDay As Integer
            wHour As Integer
            wMinute As Integer
            wSecond As Integer
            wMilliseconds As Integer
        End Type
        
        
        ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        ' NOTE: If you are using the Windows WinAPI Viewer Add-In to get
        ' function declarations, not that there is an error in the
        ' TIME_ZONE_INFORMATION structure. It defines StandardName and
        ' DaylightName As 32. This is fine if you have an Option Base
        ' directive to set the lower bound of arrays to 1. However, if
        ' your Option Base directive is set to 0 or you have no
        ' Option Base diretive, the code won't work. Instead,
        ' change the (32) to (0 To 31).
        ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        
        Private Type TIME_ZONE_INFORMATION
            Bias As Long
            StandardName(0 To 31) As Integer
            StandardDate As SYSTEMTIME
            StandardBias As Long
            DaylightName(0 To 31) As Integer
            DaylightDate As SYSTEMTIME
            DaylightBias As Long
        End Type
        
        
        ''''''''''''''''''''''''''''''''''''''''''''''
        ' These give symbolic names to the time zone
        ' values returned by GetTimeZoneInformation .
        ''''''''''''''''''''''''''''''''''''''''''''''
        
        Private Enum TIME_ZONE
    
            TIME_ZONE_ID_INVALID = 0        ' Cannot determine DST
            TIME_ZONE_STANDARD = 1          ' Standard Time, not Daylight
            TIME_ZONE_DAYLIGHT = 2          ' Daylight Time, not Standard
    
        End Enum
        
        Private Declare Function GetTimeZoneInformation Lib "kernel32" _
            (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long
        
        Private Declare Sub GetSystemTime Lib "kernel32" _
            (lpSystemTime As SYSTEMTIME)
     
        Function IntArrayToString(V As Variant) As String
    
            Dim N As Long
            Dim S As String
            For N = LBound(V) To UBound(V)
                S = S & Chr(V(N))
            Next N
            IntArrayToString = S
    
        End Function
    
        Function GetTimeZone()
    
            Dim TZI As TIME_ZONE_INFORMATION
            Dim DST As TIME_ZONE
            Dim StandardName As String
            
            DST = GetTimeZoneInformation(TZI)
            StandardName = IntArrayToString(TZI.StandardName)
            MsgBox StandardName
    
        End Function

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Running clock in excel 2010
    By Rhett21 in forum Excel General
    Replies: 1
    Last Post: 10-22-2012, 12:18 PM
  2. Excel Time zone problem
    By bittu2010 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-15-2012, 11:37 PM
  3. Need to start Clock according to Zone wise
    By marc5354 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-18-2010, 04:04 PM
  4. How to start a clock according to zone wise
    By marc5354 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-16-2010, 07:52 PM
  5. Replies: 1
    Last Post: 12-17-2005, 05:50 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1