Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: Converting to GMT


Message #1 by "Ray Pinnegar" <r.pinnegar@n...> on Mon, 30 Dec 2002 12:21:01
Hope someone can help. Seems simple but!
 
How do I convert a local Date/time e.g. Singapore to Greenwich Mean Time? 
Feel as if I 
should be able to get from the Windows regional variables.
Message #2 by braxis@b... on Mon, 30 Dec 2002 12:47:31 +0000 (GMT)
Hi Ray

These two API functions will return the local and UTC (Greenwich) - Once you've retrieved this you just need to write a function
that returns the difference between the two.

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

Private Declare Sub GetSystemTime 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

This shows how they work:

Sub Test()
    'KPD-Team 1998
    'URL: http://www.allapi.net/
    'KPDTeam@A...
    Dim SysTime As SYSTEMTIME
    Dim MyTime As SYSTEMTIME

    'Set the graphical mode to persistent
    'Get the system time
    GetSystemTime SysTime
    GetLocalTime MyTime

    'Print it to the form
    Debug.Print "The System Date is:" & SysTime.wMonth & "-" & SysTime.wDay & "-" & SysTime.wYear
    Debug.Print "The System Time is:" & SysTime.wHour & ":" & SysTime.wMinute & ":" & SysTime.wSecond
    Debug.Print "The Local Date is:" & MyTime.wMonth & "-" & MyTime.wDay & "-" & MyTime.wYear
    Debug.Print "The Local Time is:" & MyTime.wHour & ":" & MyTime.wMinute & ":" & MyTime.wSecond

End Sub

Brian

>  from:    Ray Pinnegar <r.pinnegar@n...>
>  date:    Mon, 30 Dec 2002 12:21:01
>  to:      access@p...
>  subject: Re: [access] Converting to GMT
> 
> Hope someone can help. Seems simple but!
>  
> How do I convert a local Date/time e.g. Singapore to Greenwich Mean Time? 
> Feel as if I 
> should be able to get from the Windows regional variables.


  Return to Index