Re: Unix Time Format to VB5 as string and / or Date Format



On 9/20/08 8:54 AM, in article op.uhr55prlsjedh2@hhh, "Helge Haensel"
<dj1wm@xxxxxxxxxxxxxx> wrote:

Hallo NG!
WindowsXP/HE SP3, VB5EE/SP3

The subject says it.

0x4884B5D6 (1216656854) is 19:14:14, 21 Jul 2008

That is what I need as a function.
Thanks for your help!

Did you Google for it?

Google "convert unix time format to vb" got quite a few hits. The first one
has:

Convert from UNIX Date/Time to Structured Windows Time (Updated!)
By Jason | February 2, 2007
Click Star to Rate Post
(No Ratings Yet)








At some point you may get a time value that is based on the Unix time
format. Once you understand how Unix time is setup, its easy to deal with
and display as a normal structured Date/Time in Windows. The value returned
from Unix time is the amount of seconds that have taken place since January
1st 1970. So just setup a new Date passing the 01/01/1970 value and add to
it the unix value in seconds. The code below is in VB.NET but the principals
apply to VB 5.0/6.0 and all other versions of Visual Basic.NET. A example is
below...
'
'The Unix time you want to convert.
Dim x As Double = 1089316377
'Setup a new DateTime starting at Jan 1st 1970.
Dim d As New DateTime(1970, 1, 1)
'
'Then just add the Unix value to the DateTime variable as seconds.
d = d.AddSeconds(x)
'
'Display the structured time value.
MsgBox(d.ToString)

Below is the results...



Edit: (Feb. 2nd 2008) - I want to thank Premek for commenting on this code
returning the time in UTC/GMT based time. (Universal Time Coordinated (or
Coordinated Universal Time); GMT = Greenwich Mean Time) So therefore you
will want to adjust the value based on your local time. Example: The
Messagebox screenshot image above shows the time as UTC. If your local time
is the Eastern Standard Timezone, then you would want to Subtract -5 Hours
from that time. So, if the time is 7:52:57 in UTC Time, then the time for
the Eastern Standard Time Zone (Not Daylight Savings) would be: 2:52:57.
Below is a small chart for the United States based Time Zones. Click on this
link for more information on UTC/GMT based Times...

.



Relevant Pages

  • Re: java Date to c# ticks
    ... Assuming that "ticks" are using NT Time, GIYF giving you e.g. ... How to convert Windows NT Time to UNIX Time: ...
    (comp.lang.java.programmer)
  • Re: Reading time into CTime from string
    ... Given a time offset in unix time, is it possible to use the ctime ... function much like you would in a standard windows environment? ... to string and I was informed that ctime() didn't work in Windows CE. ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: Reading time into CTime from string
    ... ctimeisn't implemented in Windows CE. ... I believe that MFC ... process that doesn't work half the time for converting from unix time ... to string and I was informed that ctime() didn't work in Windows CE. ...
    (microsoft.public.windowsce.embedded.vc)
  • measuring execution time
    ... is there a utility in windows similar to the unix time ... command that will measure the execution time and other ... Is there a utility like this in windows? ...
    (microsoft.public.windowsxp.general)
  • Re: mktime() (GAWK) question
    ... moment of the Unix time rollover)? ... yes, search for 'gawk mktime 2038', and you fill find lots of docs about it. ... Oh, I'm sure that Google is full of unofficial bug reports, but I am, of ...
    (comp.lang.awk)