Local time to UTC

namliam

The Mailman - AWF VIP
Local time
Today, 17:12
Joined
Aug 11, 2003
Messages
11,695
Hmz, OK

I want to convert local time to UTC time. For us European mainlanders that is Local minus 1 or 2 hours depending on Daylight savings time (summer -1, Winter -2).

Easy way:
get the date, and depending on the date take the time and do -1 or -2 hours.

However i would like to make it more universal. I am pretty sure one can read UTC (GMT) from windows somewhere.... Anyone have any idea?

Regards

The Mailman
 
This'll give you the offset.

Code:
Private Declare Function GetTimeZoneInformation Lib "kernel32" (lpTimeZoneInformation As TimeZoneInfo) As Long

Private Type SystemTime
        intYear As Integer
        intMonth As Integer
        intwDayOfWeek As Integer
        intDay As Integer
        intHour As Integer
        intMinute As Integer
        intSecond As Integer
        intMilliseconds As Integer
End Type


Private Type TimeZoneInfo
        lngBias As Long
        intStandardName(32) As Integer
        intStandardDate As SystemTime
        intStandardBias As Long
        intDaylightName(32) As Integer
        intDaylightDate As SystemTime
        intDaylightBias As Long
End Type

Private Sub Form_Load()
    Dim lngRet As Long
    Dim udtTZI As TimeZoneInfo
    
    lngRet = GetTimeZoneInformation(udtTZI)
    MsgBox "Adjust your time by " & udtTZI.lngBias & " minutes"
End Sub
 
Mile, works verry nicely, but.. how?

Where did you get this?

?? I dont like implementing stuff i dont understand...

Regards
 
I have been searching half the morning !

Darn!
 
Does anyone know about this(time zone)

Well the code works for me but it doesn't work when I change the time in my system, it keeps telling me that the difference is 5 yours even though I changed the date to october 1st which is shoudl tell me 4 hours and not 5 hours, it looks like the code is not reading future dates from my machine. anyone has a clue!!
 
It worked perfectly for me, and have never heard any complaints from my customers in over two years!
 
did you try changing the time and date in your system and see what results you get? thanks. the current difference is 5 hours but try change the date to october and see if it gives you the time as 4 hours because that's what should happen. thanks.
 
I did at the time... not recently.

That was for another customer too.... And currently dont have the ability to change it. Sorry...
 

Users who are viewing this thread

Back
Top Bottom