Greenwich GMT Date and Time problem

G

gmazza

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
 
G

gmazza via AccessMonster.com

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!
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
 
D

Douglas J. Steele

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

(no private e-mails, please)


gmazza via AccessMonster.com said:
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!
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top