WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Time - Timer and Date Functions
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

FileTime in GMT format

Keywords: 	 FileTime in GMT format.wbt

Here's a routine that will get the GMT file time, returned in YmdHms format.
;--------------------------------------------
;  Given a file name, gets the
;  file "Last Modify" time in GMT.
;
;  Returns the time as YYYY:MM:DD:HH:MM:SS
;
;  If the file is not found, returns ""
;--------------------------------------------

#DefineFunction GMTFileTime(TheFile)
  Kernel32 = DllLoad(strcat(dirwindows(1),"Kernel32.DLL"))
  Data = BinaryAlloc(320)

  Handle = DllCall(Kernel32,long:"FindFirstFileA",lpstr:TheFile,lpbinary:Data)
  if Handle == -1 ; File Not Found?
    BinaryFree(Data)
    DllFree(Kernel32)
    return ""
  endif
  DllCall(Kernel32,long:"FindClose",long:Handle)
  FT = BinaryAlloc(8)
  BinaryCopy(FT,0,Data,12,8)
  DllCall(Kernel32,long:"FileTimeToSystemTime",lpbinary:FT,lpbinary:Data)
  DllFree(Kernel32)
  BinaryFree(FT)

  Y = BinaryPeek2(Data,0)
  M = StrFixLeft(BinaryPeek2(Data,2),"0",2)
  D = StrFixLeft(BinaryPeek2(Data,6),"0",2)
  H = StrFixLeft(BinaryPeek2(Data,8),"0",2)
  N = StrFixLeft(BinaryPeek2(Data,10),"0",2)
  S = StrFixLeft(BinaryPeek2(Data,12),"0",2)
  BinaryFree(Data)
  return StrCat(Y,":",M,":",D,":",H,":",N,":",S)
#EndFunction



FileTIme = GMTFileTime("Some\File")

Article ID:   W15720
File Created: 2005:11:01:10:59:08
Last Updated: 2005:11:01:10:59:08