If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
Greenwich GMT Date and Time problem
Hey there,
I have the following code in a module that I am calling the GetZuluTime() in a text field on a form and my time is Mountain time, and its 4pm here now and it is showing up as 10pm for some reason. What I want is when a user NOT in my time zone uses this form, it needs to record the time of their updates in a table. See anything wrong?? Private Const LOCALE_SYSTEM_DEFAULT& = &H800 '********************************** '** Type Definitions: 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 Declare Sub GetSystemTime Lib "Kernel32" (lpSystemTime As SYSTEMTIME) Private Declare Function GetTimeFormat& Lib "Kernel32" Alias _ "GetTimeFormatA" (ByVal Locale As Long, ByVal dwFlags As Long, _ lpTime As SYSTEMTIME, ByVal lpFormat As Long, _ ByVal lpTimeStr As String, ByVal cchTime As Long) Public Function GetZuluTime() As Date Dim myTime As SYSTEMTIME Dim strBuffer As String Dim lng As Long Dim strSystemTime As String GetSystemTime myTime strBuffer = String$(255, Chr$(0)) lng = GetTimeFormat&(LOCALE_SYSTEM_DEFAULT, 0, myTime, _ 0, strBuffer, 254) With myTime GetZuluTime = DateSerial(.wYear, .wMonth, .wDay) _ + CDate(strBuffer) End With End Function -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/200904/1 |
#2
|
|||
|
|||
Greenwich GMT Date and Time problem
What's actually in strBuffer after your call to GetTimeFormat?
You might take a look at http://www.mvps.org/access/api/api0024.htm at "The Access Web" to ensure you're also handling daylight savings time properly. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "gmazza" u37142@uwe wrote in message news:94446eb6ff00f@uwe... Hey there, I have the following code in a module that I am calling the GetZuluTime() in a text field on a form and my time is Mountain time, and its 4pm here now and it is showing up as 10pm for some reason. What I want is when a user NOT in my time zone uses this form, it needs to record the time of their updates in a table. See anything wrong?? Private Const LOCALE_SYSTEM_DEFAULT& = &H800 '********************************** '** Type Definitions: 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 Declare Sub GetSystemTime Lib "Kernel32" (lpSystemTime As SYSTEMTIME) Private Declare Function GetTimeFormat& Lib "Kernel32" Alias _ "GetTimeFormatA" (ByVal Locale As Long, ByVal dwFlags As Long, _ lpTime As SYSTEMTIME, ByVal lpFormat As Long, _ ByVal lpTimeStr As String, ByVal cchTime As Long) Public Function GetZuluTime() As Date Dim myTime As SYSTEMTIME Dim strBuffer As String Dim lng As Long Dim strSystemTime As String GetSystemTime myTime strBuffer = String$(255, Chr$(0)) lng = GetTimeFormat&(LOCALE_SYSTEM_DEFAULT, 0, myTime, _ 0, strBuffer, 254) With myTime GetZuluTime = DateSerial(.wYear, .wMonth, .wDay) _ + CDate(strBuffer) End With End Function -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/200904/1 |
#3
|
|||
|
|||
Greenwich GMT Date and Time problem
Honestly, I used this code from an example on the forums that people said
worked. I just have it in a module, and I set up a text field and gave it a source of =GetZuluTime() and its coming out with a time of 6 hours later. I looked at the example you gave me the link to and Daylight Savings is a big one. Where would I put that code, just in a module? How would I call it, or display the actual time? Thanks for your help! Douglas J. Steele wrote: What's actually in strBuffer after your call to GetTimeFormat? You might take a look at http://www.mvps.org/access/api/api0024.htm at "The Access Web" to ensure you're also handling daylight savings time properly. Hey there, I have the following code in a module that I am calling the GetZuluTime() [quoted text clipped - 46 lines] End Function -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/200904/1 |
#4
|
|||
|
|||
Greenwich GMT Date and Time problem
Terry's code isn't actually directly related to your question. Hopefully,
though, you can see from it how you'd adjust for daylight savings time. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "gmazza via AccessMonster.com" u37142@uwe wrote in message news:945995bae112c@uwe... Honestly, I used this code from an example on the forums that people said worked. I just have it in a module, and I set up a text field and gave it a source of =GetZuluTime() and its coming out with a time of 6 hours later. I looked at the example you gave me the link to and Daylight Savings is a big one. Where would I put that code, just in a module? How would I call it, or display the actual time? Thanks for your help! Douglas J. Steele wrote: What's actually in strBuffer after your call to GetTimeFormat? You might take a look at http://www.mvps.org/access/api/api0024.htm at "The Access Web" to ensure you're also handling daylight savings time properly. Hey there, I have the following code in a module that I am calling the GetZuluTime() [quoted text clipped - 46 lines] End Function -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/200904/1 |
Thread Tools | |
Display Modes | |
|
|