Windows regional time setting

Posted on 2011-10-07
Last Modified: 2012-05-12
I'm trying to customize an Access application that stores appointment date/times in a SharePoint list.

Unfortunately, I've got users all over the US that are using this application.  What I want to happen is that when the user selects 10am, and then saves the record, the value that actually gets saved will be in GMT.  So I need a way to convert a local time to GMT.  I'm assuming that the best way to do this is via an api call or by capturing a registry setting.  Just not sure how to accomplish this.

I'll either use the forms Current event or a conversion function in a query to convert the saved date/time back to local time for display purposes
Question by:Dale Fye (Access MVP)
    LVL 119

    Expert Comment

    by:Rey Obrero
    LVL 39

    Expert Comment

    LVL 48

    Expert Comment

    by:Gustav Brock
    Here is full code and how to do. Just pick the right page at EE:

    Convert PST time to GMT

    LVL 26

    Accepted Solution

    I'll go one better, since you need multiple zones across the continent
    was the source
    <singing, it's all been done before>
    For my machine it returns "Mountain Daylight Time"

      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

            Bias As Long
            StandardName(32) As Integer
            StandardDate As SYSTEMTIME
            StandardBias As Long
            DaylightName(32) As Integer
            DaylightDate As SYSTEMTIME
            DaylightBias As Long
    End Type

    Declare Function GetTimeZoneInformation Lib "kernel32.dll" (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long

    Function TimeZoneString() As String
    ' Display the name of the time zone the computer is set to.
    Dim tzi As TIME_ZONE_INFORMATION  ' receives information on the time zone
    Dim retval As Long  ' return value
    Dim c As Long  ' counter variable needed to display time zone name
    Dim TheZone As String

    retval = GetTimeZoneInformation(tzi)  ' read information on the computer's selected time zone

    ' Oddly, instead of being stored in a string, the time zone name is stored in a
    ' 32-element array, each element holding the ASCII code of one of the characters.
    ' This loop converts the array into a readable string.
    For c = 0 To 31  ' the array's range is from 0 to 31
      If tzi.StandardName(c) = 0 Then Exit For  ' abort if the terminating null character is reached
      TheZone = TheZone & Chr(tzi.StandardName(c)) ' convert the ASCII code into a character
    Next c
    TimeZoneString = TheZone
    End Function

    Form there, it's a select case structure and you're done
    LVL 47

    Author Comment

    by:Dale Fye (Access MVP)
    not abandoned, just side-tracked.  Will get back to you.
    LVL 47

    Author Closing Comment

    by:Dale Fye (Access MVP)

    This worked like a charm.  Thanks

    Don't know how I failed to close this sooner
    LVL 26

    Expert Comment

    No problem
    LVL 26

    Expert Comment

    No problem

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Suggested Solutions

    No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
    Outlook Free & Paid Tools
    The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    733 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now