jhLewis wrote:
Using vb6, I would like to have either a text box or label display the
current time in UTC format...I can't seem to find any instructions or code
snippets on how to accomplish it...
Any help appreciated...thanks.
John
I used this code. I cut-and-pasted it, so help yourself.
'After this point, I cut and pasted code from a Visual Basic group to
'try and help with the timezone problem.
Const TIME_ZONE_ID_INVALID = &HFFFFFFFF
Const TIME_ZONE_ID_UNKNOWN = &H0
Const TIME_ZONE_ID_STANDARD = &H1
Const TIME_ZONE_ID_DAYLIGHT = &H2
Type TIME_ZONE_INFORMATION
Bias As Long
StandardName As String * 32
StandardDate As Long
StandardBias As Long
DaylightName As String * 32
DaylightDate As Long
DaylightBias As Long
End Type
Declare Function GetTimeZoneInformation Lib "kernel32" _
(lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long
Function NowPlusTZBias() As Date
Dim usrTZI As TIME_ZONE_INFORMATION
Dim lngRetVal As Long
lngRetVal = GetTimeZoneInformation(usrTZI)
NowPlusTZBias = Now + (usrTZI.Bias / 1440)
End Function
To use it in the program, do this:
'If this is true, we're using Windows Time. Note that we have to
'compenstate for the timezone and use UTC. The NowPlusTZ Biaswas
'code taken from a MS access? newsgroup.
data_out(1) = CByte(Year(NowPlusTZBias) - 2000)
data_out(2) = CByte(Month(NowPlusTZBias))
data_out(3) = CByte(Day(NowPlusTZBias))
data_out(4) = CByte(Hour(NowPlusTZBias))
data_out(5) = CByte(Minute(NowPlusTZBias))
data_out(6) = CByte(Second(NowPlusTZBias))
In other words, copy the first part into your code (as I did) and
instead of using Now, use NowPlusTZBias
--
Magnus McElroy
Electrical Engineer (EIT)
HABIT Research
(250) 381-9425