title: How to get last modified date of file
body: <p>I'm trying to get the last modified date of a file and this turns out to be more complicated than I thought. My first attempt was this:</p>
  
  <pre><code>hFile = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
  GetFileTime(hFile, &amp;creationTime, &amp;lastAccessTime, &amp;lastWriteTime);     
  FileTimeToSystemTime(&amp;lastWriteTime, &amp;t);
  
  printf("TEST: %d %d %d\n", t.wHour, t.wMinute, t.wSecond);
  </code></pre>
  
  <p>I've tested this with a file on my HD whose last modified date is reported by Explorer as Friday 21st March, 1997, 14:34:58. Now with the code above I got the same date except that the time is reported as 13:34:58, i.e. one hour off. So I thought this is probably related to missing timezone/DST adjustments so I added a call to <code>FileTimeToLocalTime()</code>, i.e. like this:</p>
  
  <pre><code>hFile = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
  GetFileTime(hFile, &amp;creationTime, &amp;lastAccessTime, &amp;lastWriteTime);
  FileTimeToLocalFileTime(&amp;lastWriteTime, &amp;ft);               
  FileTimeToSystemTime(&amp;ft, &amp;t);
  </code></pre>
  
  <p>But now the time is reported as 15:34:58, i.e. still one hour off but now in the opposite direction. So I still don't get the 14:34:58 as reported by Explorer. </p>
  
  <p>That's why I'd like to ask how I can get the last modified date as reported by Explorer. Anyone?</p>