Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Win32ToVbTime

Status
Not open for further replies.

BOEstooge

Technical User
May 18, 2004
1
US
I am running an FTP program in VB 6.0. When I link to my IBM AS400 UNIX system the time displayed in the FTP program is as 7 hours less than the actual UNIX system time.

These are my Declared statements:

Private Const rDayZeroBias As Double = 109205# ' Abs(CDbl(#01-01-1601#))
'Private Const rMillisecondPerDay As Double = 10000000# * 60# * 60# * 24# / 10000# '= 86400000

Private Declare Function FileTimeToLocalFileTime Lib "kernel32" (lpFileTime As Any, lpLocalFileTime As Any) As Long

This is the function I am Calling.

Private Function Win32ToVbTime(ft As Currency) As Date
Dim ftl As Currency
' Call API to convert from UTC time to local time
If FileTimeToLocalFileTime(ft, ftl) Then
' Local time is nanoseconds since 01-01-1601
' In Currency that comes out as milliseconds
' Divide by milliseconds per day to get days
' since 1601
' Subtract days from 1601 to 1899 to get VB
' Date equivalent
Win32ToVbTime = CDate_
((ftl / rMillisecondPerDay) - rDayZeroBias)
Else
MsgBox Err.LastDllError
End If
End Function

Can anyone tell me how to correct this problem? I have been all over the internet and have found nothing.
 
Looks like one of your time systems is based on UTC (aka Greenwich Mean Time) and one is based on your local time. There are a couple of APIs that do the conversion:


________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top