Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Retrieving time difference between time zones

Posted on 2005-05-09
6
Medium Priority
?
224 Views
Last Modified: 2010-07-27
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...
0
Comment
Question by:cartti
6 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 13961421
0
 
LVL 13

Expert Comment

by:rettiseert
ID: 13961771
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
 
LVL 2

Author Comment

by:cartti
ID: 13964194
Thanks rettiseert, that's certainly useful. Though how would I determine if it's GMT or BST in London (without hardcoding the dates)?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 28

Accepted Solution

by:
Ark earned 700 total points
ID: 13964196
Hi
See my sample at http://www.freevbcode.com/ShowCode.Asp?ID=1749 <<Convert Times Across Different Time Zones>>
0
 
LVL 2

Author Comment

by:cartti
ID: 13964219
That's brilliant Ark, exactly what I was looking for. Thanks to all for your help!
0
 
LVL 28

Expert Comment

by:Ark
ID: 13964244
Thanks for points, glad I could help
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question