Re: Unix Time Format to VB5 as string and / or Date Format
- From: winston19842005 <bjjlyates@xxxxxxxxxxxxxxxxxxx>
- Date: Sat, 20 Sep 2008 09:00:29 -0400
On 9/20/08 8:54 AM, in article op.uhr55prlsjedh2@hhh, "Helge Haensel"
<dj1wm@xxxxxxxxxxxxxx> wrote:
Hallo NG!Did you Google for it?
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!
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...
.
- Follow-Ups:
- Re: Unix Time Format to VB5 as string and / or Date Format
- From: Helge Haensel
- Re: Unix Time Format to VB5 as string and / or Date Format
- References:
- Unix Time Format to VB5 as string and / or Date Format
- From: Helge Haensel
- Unix Time Format to VB5 as string and / or Date Format
- Prev by Date: Unix Time Format to VB5 as string and / or Date Format
- Next by Date: Re: Unix Time Format to VB5 as string and / or Date Format
- Previous by thread: Unix Time Format to VB5 as string and / or Date Format
- Next by thread: Re: Unix Time Format to VB5 as string and / or Date Format
- Index(es):
Relevant Pages
|