473,385 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

vb6 UTC time?

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
Aug 17 '05 #1
3 22944


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
Aug 17 '05 #2

"Magnus McElroy" <"[myfirstname]"@habitresearch.[com]> wrote in message
news:NyMMe.34735$vj.3766@pd7tw1no...


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


Is there a reason why seemingly nobody used the GetSystemTime funtion and
does all this crazy adding and subtracting?

Keith R. Weimer
Way Too Happy Software
Aug 19 '05 #3


Keith R. Weimer wrote:
*snip*


Is there a reason why seemingly nobody used the GetSystemTime funtion and
does all this crazy adding and subtracting?

Keith R. Weimer
Way Too Happy Software


Nope, no reason. It was just the first solution I found. It works, so
there's no point in changing it.

--
Magnus McElroy
Electrical Engineer (EIT)
HABIT Research
(250) 381-9425
Aug 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Szabolcs Nagy | last post by:
I have to measure the time of a while loop, but with time.clock i always get 0.0s, although python manual sais: "this is the function to use for benchmarking Python or timing algorithms" So i...
6
by: cournape | last post by:
Hi there, I have some scientific application written in python. There is a good deal of list processing, but also some "simple" computation such as basic linear algebra involved. I would like to...
6
by: Rebecca Smith | last post by:
Today’s question involves two time text boxes each set to a different time zone. Initially txtCurrentTime will be set to Pacific Time or system time. This will change with system time as we travel...
3
by: luscus | last post by:
Thanks for all the responses on my first question. Unfortunately the answers I was given were too complicated for my small brain , and neophite condition to understand. So if you could talk down to...
0
by: Edward Diener | last post by:
In Borland's VCL it was possible to divide a component into design time and run time DLLs. The design time DLL would only be necessary when the programmer was setting a component's properties or...
1
by: Alfonso Morra | last post by:
Hi I'm compiling some code and need to generate some random numbers. To save time, I decided to use the srand, rand and time functions. My code worked (atleast built fine) until I added time.h,...
3
by: cj | last post by:
If I want to check to see if it's after "11:36 pm" what would I write? I'm sure it's easy but I'm getting tired of having to work with dates and times. Sometimes I just want time or date. And...
6
by: Luvin lunch | last post by:
Hi, I'm new to access and am very wary of dates as I have limited experience in their manipulation and I know if they're not done properly things can turn ugly quickly. I would like to use a...
1
by: davelist | last post by:
I'm guessing there is an easy way to do this but I keep going around in circles in the documentation. I have a time stamp that looks like this (corresponding to UTC time): start_time =...
2
by: Roseanne | last post by:
We are experiencing very slow response time in our web app. We run IIS 6 - windows 2003. I ran iisstate. Here's what I got. Any ideas?? Opened log file 'F:\iisstate\output\IISState-812.log'...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.