FromFileTime Off by 1 hr

  • Thread starter Thread starter Sunit Joshi
  • Start date Start date
S

Sunit Joshi

Hell All
I'm trying to get the file time adjusted to localtime using the
DateTime.FromFileTime(long fileTime) method. But I'm seeing that the
time is lesser by 1hr when I get the same using win32API.

This is what I have for the C# code:
static long lowTime = 1175519056 ;
static long highTime = 29537814;
highTime = (highTime<<32);
highTime = highTime + (uint) lowTime;
DateTime netTime = DateTime.FromFileTime(highTime);
Console.WriteLine("Converted DBTime: " + netTime.ToString());

This gives: Converted DBTime: 1/7/2003 12:30:30 AM

While the VB6 one gives: 1/7/2003 1:30:30
using this code for a quick-check

Public Function GetFileLocalTimeFromUTC(fileTimeStruct As FILETIME) As
String
Dim fout As FILETIME, SysTime As SYSTEMTIME
Dim sOut As String

FileTimeToLocalFileTime fileTimeStruct, fout 'WIN-API
FileTimeToSystemTime fout, SysTime 'WIN-API

sOut = LTrim(Str$(SysTime.wMonth)) + "/" +
LTrim(Str$(SysTime.wDay)) + "/" + LTrim(Str$(SysTime.wYear))
sOut = sOut & " " & LTrim(Str$(SysTime.wHour)) + ":" +
LTrim(Str$(SysTime.wMinute)) + ":" + LTrim(Str$(SysTime.wSecond))

GetFileLocalTimeFromUTC = sOut
End Function

I'm in Central-Time zone.

thanks
(e-mail address removed)
 
Back
Top