Important alert: (current site time 7/16/2013 4:08:37 AM EDT)
 

VB icon

Calculate InternetTime

Email
Submitted on: 6/19/1999
By: Hiu-Hong Hau  
Level: Not Given
User Rating: By 2 Users
Compatibility: VB 4.0 (32-bit), VB 5.0, VB 6.0
Views: 26266
 
     The function InternetTime() calculates the internettime, the new time standard from Swatch. You only have to call the function.
 

Windows API/Global Declarations:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
'Windows API/Global Declarations for :Calculate InternetTime
'**************************************
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'*****************************************************************'
'* The function InternetTime() returns the current time *'
'* in beats. The code to determine the timezone has been written *'
'* by Dror Saddan (drors@ietusa.com).*'
'* The code to calculate the internettime has been written by*'
'* Swatch. I have ported it to Visual Basic. *'
'**'
'* Written by Hiu-Hong Hau (hhhau@dds.nl)*'
'* Date: June 20th 1999 *'
'* Website: http://www.supervisie.nl/qlaunch *'
'* Website: http://www.supervisie.nl/gemini *'
'**'
'* Take a look at QuickLaunch, a skinnable application launcher, *'
'* completely written in Visual Basic.*'
'*****************************************************************'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Type SYSTEMTIME ' 16 Bytes
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
Public Type TIME_ZONE_INFORMATION
Bias As Long
StandardName(31) As Integer
StandardDate As SYSTEMTIME
StandardBias As Long
DaylightName(31) As Integer
DaylightDate As SYSTEMTIME
DaylightBias As Long
End Type
Public Declare Function GetTimeZoneInformation Lib "kernel32" (lpTimeZoneInformation _
As TIME_ZONE_INFORMATION) As Long
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: Calculate InternetTime
' Description:The function InternetTime() calculates the internettime, the new time standard from Swatch. You only have to call the function.
' By: Hiu-Hong Hau
'
' Returns:This function returns a value containing the internettime. If you want to convert it to a small string, you could use the following: Mid(Format(MyTime, "000.0000000"), 1, 3)
'
' Assumes:Copy and Paste all of these code in one single module.
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=2131&lngWId=1'for details.'**************************************

Public Function GetTimeZone(Optional ByRef strTZName As String) As Long
Dim objTimeZone As TIME_ZONE_INFORMATION
Dim lngResult As Long
Dim i As Long
lngResult = GetTimeZoneInformation&(objTimeZone)
Select Case lngResult
 Case 0&, 1& 'use standard time
 GetTimeZone = -(objTimeZone.Bias + objTimeZone.StandardBias) 'into minutes
 For i = 0 To 31
 If objTimeZone.StandardName(i) = 0 Then Exit For
 strTZName = strTZName & Chr(objTimeZone.StandardName(i))
 Next
 Case 2& 'use daylight savings time
 GetTimeZone = -(objTimeZone.Bias + objTimeZone.DaylightBias) 'into minutes
 For i = 0 To 31
 If objTimeZone.DaylightName(i) = 0 Then Exit For
 strTZName = strTZName & Chr(objTimeZone.DaylightName(i))
 Next
End Select
End Function
Public Function InternetTime()
Dim tmpH
Dim tmpS
Dim tmpM
Dim itime
Dim tmpZ
Dim testtemp As String
tmpH = Hour(Time)
tmpM = Minute(Time)
tmpS = Second(Time)
tmpZ = GetTimeZone
itime = ((tmpH * 3600 + ((tmpM - tmpZ + 60) * 60) + tmpS) * 1000 / 86400)
If itime > 1000 Then
 itime = itime - 1000
ElseIf itime < 0 Then
 itime = itime + 1000
End If
InternetTime = itime
End Function


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

6/20/1999 6:54:00 AMcydonia76

This code is stuffed. Yeah, it sounds good
but what the hell does it do? If somebody
can make use of this code, then i would like to know how!
(If this comment was disrespectful, please report it.)

 
6/20/1999 7:05:00 AMH.H.Hau

What does it do? Well, it calculates the internettime. It may not be of much use for you, but others may incorporate this code in their own clock or something. You can goto http://www.swatch.com/internettime/fs_time.html for an explanation of what internettime is.
(If this comment was disrespectful, please report it.)

 
6/20/1999 9:51:00 AMJames

I tried out your code, and checked it
against the converter on the swatch site.
Your code doesn't seem to be calculating
time zones correctly, as I'm getting an
Internet time 3 hours ahead of what it should
be.
(If this comment was disrespectful, please report it.)

 
6/20/1999 12:35:00 PMH.H.Hau

That's odd! I've changed different computers here to different timezones and it worked for me... Really odd. I also tested on DayLight savings, also succesfull. What timezone are you in?
(If this comment was disrespectful, please report it.)

 
6/20/1999 1:28:00 PMRobb

Worked great for me even the time zone worked fine. I think I'll keep the code around just in case this Internet time catch's on, along with the one world order :)
(If this comment was disrespectful, please report it.)

 
6/21/1999 10:59:00 AMJames

Possibly I am doing something wrong then.
Do I put the two functions into the module,
or into the code for my form?
And what would be the correct way to call
the function?
(If this comment was disrespectful, please report it.)

 
6/21/1999 12:55:00 PMH.H.Hau

Put all the code in one single module. Make on your form a button and a label and onclick event for the button e.g. label1.caption=InternetTime()
that should work.
(If this comment was disrespectful, please report it.)

 
7/2/1999 9:03:00 PMchris

can somebody teach me how to do a calculator
on calculate time rate :)
(If this comment was disrespectful, please report it.)

 
7/7/1999 12:01:00 PMmikeg

"InternetTime" is about the dumbest idea I've heard in a long time. Years and years ago GMT (Greenwich Mean Time) was established as the 'universal time' (GMT is the same as "CUT" or Coordinated Universal Time, also known as "UCT"). GMT (or UCT) is the same no matter where you are in the universe. I can't believe Swatch has complicated our lives by introducing a new time standard. (In the USA) call (303) 499-7111 to hear the NIST atomic clock in Colorado tell you what time it REALLY is. There's also a web site at http://hpv17.infosys.tuwien.ac.at/AtomZeit/HowsTheTime.pl that displays UCT according to an atomic clock at the Vienna University of Technology.
I hope people don't take Swatch seriously! It's totally regressive to consider using some other "mean time".
(If this comment was disrespectful, please report it.)

 
7/9/1999 4:45:00 AMAndy

mikeg : if you dont like this, you're going to love the french :)

A few weeks ago they decided to abandon GMT/UCT/CUT and make their own meridian running through paris. Now thats just silly.
(If this comment was disrespectful, please report it.)

 
7/9/1999 4:47:00 AMAndy

Great code by the way :)
(If this comment was disrespectful, please report it.)

 
7/14/1999 4:38:00 PMjdallen

Mikeg. This site is for expression of ideas in the programming world. Why not take Swatch seriously, the world is do for a change cuz its starting to get doaring. Just think, how many people do you really think call for the time any ways. I don't, its a wast of time. Why not make it so all you have to do is "one click for time, two clicks for temp." :-)
(If this comment was disrespectful, please report it.)

 
7/14/1999 4:40:00 PMjdallen

Greate code.
(If this comment was disrespectful, please report it.)

 
7/15/1999 3:47:00 AMH.H.Hau

Thanx, at least somebody is happy with my code! :P
(If this comment was disrespectful, please report it.)

 
7/15/1999 11:29:00 AMroberto

I really is a good program; however, I would suggets to add something more
productive such as location visited and time spent on them

otherwise congratulations !!!!
(If this comment was disrespectful, please report it.)

 
7/26/1999 7:38:00 AMbob

I tryed the code and i get error on the line :
strTZName = strTZName & Chr(objTimeZone.DaylightName(i))
The error is :
"Run-time error '5': Invalid procedure call or argument"
can someone help me?
(If this comment was disrespectful, please report it.)

 
7/28/1999 9:17:00 PMtoto

please help me , i have database in sql server and then in visual basic i use ADO so how can i save or addnew data in vb with ADO
thanks
(If this comment was disrespectful, please report it.)

 
7/28/1999 9:19:00 PMtoto

hallo
test
test
test

(If this comment was disrespectful, please report it.)

 
7/31/1999 4:02:00 PMFlaperman

I cannot make use of this code, and i also think that it is a rotten code...

Flaperman, Denmark
(If this comment was disrespectful, please report it.)

 
8/2/1999 12:57:00 PMFlash

Hi,
the code worked fine for me but...
In what format does it display the time????
I get 992.4652777777 when I was conected 1:08 hours....

Can you please explain me?
Thanks You

Flash
ICQ 3233432
(If this comment was disrespectful, please report it.)

 
8/12/1999 12:13:00 PMDexter

Honestly I have to say I haven't tried your code yet but it browsed my interest because I was wondering how can I get the time in milliseconds?

I was thinking maybe with "TimeGetSystem" but I haven't had any success finding any good examples of it. I would appreciate it if you could point me in the right direction.

Thanks,

Dexter
(If this comment was disrespectful, please report it.)

 
8/28/1999 7:51:00 AMjagdish

this seems to be intresting and useful but my needs are a bit different
i avtually want to find how much time i am connected on to net. i am actually launching the application
after which i want to fine this application is of some third party user but once it starts the net i want to find the tiem .
will this be useful please help and plese mail back on how to do.

thanx in advance
jagdish
(If this comment was disrespectful, please report it.)

 
9/15/1999 2:27:00 AMSudkhet Thepphornphitak

Please message to me
(If this comment was disrespectful, please report it.)

 
9/17/1999 8:34:00 AMChris

>the code worked fine for me but...
>In what format does it display the
>time????
>I get 992.4652777777 when I was conected 1:08 hours....

The "Internet Time" has nothing to do with the time you have been connected to the internet. It is a new invention by
Swatch, Switzerland which does basically the same as GMT/universal time: a method to compare the time worldwide.

The day is divided into 1000 intervals (one equals about 1 min 26 sec),
so I was almost "midnight" when your computer said it was "992".
According to Swatch, the Internet Time is supposed to be useful
for "chatters", because people can meet at a certain "internet time",
which is the same on the whole planet, online.
(If this comment was disrespectful, please report it.)

 
9/17/1999 3:10:00 PMvb-boy

please send this source in a zip to koffe1@hotmail.com
PLEASE!
(If this comment was disrespectful, please report it.)

 
10/22/1999 1:05:00 AMTM Daemon

Nice idea!!!
I can actually use this to set all my workstation times to my Unix server!

(If this comment was disrespectful, please report it.)

 
11/17/1999 9:16:00 PMsung

anybody know how to this code..
if you got completed code,
please send me !
basic@altavista.co.kr
have nice a day ;-)
(If this comment was disrespectful, please report it.)

 
12/5/1999 2:42:00 PMOliver T

You mustn't only write the function for displaying it all correct! You hvae to wirte object.caption = (CInt(Internettime)) !
CU OLIVER

See my programs @ planet-source-code!!
(If this comment was disrespectful, please report it.)

 
2/7/2000 12:52:16 AMRob Wise

code works fine for me and it quite impressive coding, very useful if this internet time ever catches on.
(If this comment was disrespectful, please report it.)

 
3/2/2002 2:39:43 PMDuy Nguyen

Please tell me how to use this code
(If this comment was disrespectful, please report it.)

 
3/2/2002 3:35:02 PMDuy Nguyen

Please tell me how to use this code please. Softw4re@Yahoo.Com Thank YOu
(If this comment was disrespectful, please report it.)

 
2/7/2004 8:55:45 PM

Coding is fun when it is a useless challenge. Great piece of coding man. Keep going!
(If this comment was disrespectful, please report it.)

 
3/28/2005 3:37:53 AM

why u upload just code not includes form
(If this comment was disrespectful, please report it.)

 
8/22/2006 10:57:54 PMNexson Oandasan

Nice program
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.