Retrieving time difference between time zones

Hi,

How do I determine how many hours my system clock is behind or infront of the time in London? I'm sure the last time I attempted to get this information, I was stopped short in my tracks by whether it was GMT or BST (+1 hour). I also know that when clocks go forward or backwards by an hour due to daylight saving, there can be a wait of a week or so for time zones to sync up.

Thanks in advance...
LVL 2
carttiAsked:
Who is Participating?
 
ArkConnect With a Mentor Commented:
Hi
See my sample at http://www.freevbcode.com/ShowCode.Asp?ID=1749 <<Convert Times Across Different Time Zones>>
0
 
GrahamSkanRetiredCommented:
0
 
rettiseertCommented:
This also may help:

Option Explicit

Private Declare Sub GetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
Private Declare Sub GetLocalTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)

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

Private Sub Form_Load()

    MsgBox "Current time in london (no daylight saving): " + CStr(GetSystemTimeVB) + vbCrLf + _
    "Current time here (with daylight saving): " + CStr(GetLocalTimeVB) + vbCrLf

End Sub

Private Function GetSystemTimeVB() As Date

    Dim SysTime As SYSTEMTIME

    GetSystemTime SysTime
   
    GetSystemTimeVB = DateSerial(SysTime.wYear, SysTime.wMonth, SysTime.wDay) + TimeSerial(SysTime.wHour, SysTime.wMinute, SysTime.wSecond)

End Function

Private Function GetLocalTimeVB() As Date

    Dim SysTime As SYSTEMTIME

    GetLocalTime SysTime
   
    GetLocalTimeVB = DateSerial(SysTime.wYear, SysTime.wMonth, SysTime.wDay) + TimeSerial(SysTime.wHour, SysTime.wMinute, SysTime.wSecond)

End Function
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
carttiAuthor Commented:
Thanks rettiseert, that's certainly useful. Though how would I determine if it's GMT or BST in London (without hardcoding the dates)?
0
 
carttiAuthor Commented:
That's brilliant Ark, exactly what I was looking for. Thanks to all for your help!
0
 
ArkCommented:
Thanks for points, glad I could help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.