Obtaining Universal Coordinated Time (UTC) from NTFS Files

This article was previously published under Q158588
After the automatic correction for Daylight Saving Time, monitoringprograms comparing current time/date stamps to reference data that were notwritten using Win32 API calls which directly obtain/adjust to UniversalCoordinated Time (UTC) will erroneously report time/date changes on files.Programs affected by this issue may include version-control software,database-synchronization software, software-distribution packages, backupsoftware not written with NTFS-awareness, and so on.
When Windows NT automatically adjusts for Daylight Saving Time, thetime/date stamp on files on NTFS volumes and the events in the event logsappear to be shifted by one hour, even though the files and event recordswere last created/changed prior to the Daylight Saving Time adjustment.

This behavior occurs because of the way that Windows NT stores time/datestamp information. All time/dates displayed in Event Log events and fileson NTFS partitions are computed as offsets to UTC (which is the same asGreenwich Mean Time [GMT]). When you select your time-zone from the ControlPanel Date/Time applet, you are setting the value for UTC. The appropriatenumber of hours are then added or subtracted to/from the stored UTC value.This adjusted time is then displayed in any operation which reports localtime (that is, NT Explorer [NT 4.0], File Manager, directory listings, andso on). When "Automatically Adjust for Daylight Saving Time" is selected,an additional hour is added to GMT during Daylight Saving Time (the firstSunday in April through the last Sunday in October).
By rewriting the affected application(s) to use the appropriate Win32 APIcalls, this problem can be corrected. Under NTFS, the Win32 APIGetFileTime() returns the create time, last access time, and last writetime for the specified file. The times returned are in UniversalCoordinated Time (UTC). This is also the time that NTFS uses to calculatelocal time/date information. You can use FileTimeToLocalFileTime() toconvert a UTC file time to a local time. However, if you automaticallyadjust for Daylight Saving Time, FileTimeToLocalFileTime() will adjust forDaylight Saving Time based on whether the current date should be adjustedfor Daylight Saving Time, not based on whether the date returned byGetFileTime API call should be adjusted.

Αναγνωριστικό άρθρου: 158588 - Τελευταία αναθεώρηση: 02/26/2007 19:38:34 - Αναθεώρηση: 2.3

Microsoft Windows 2000 Server, Microsoft Windows 2000 Advanced Server, Microsoft Windows 2000 Professional Edition, Microsoft Windows NT Workstation 3.5, Microsoft Windows NT Workstation 3.51, Microsoft Windows NT Workstation 4.0 Developer Edition, Microsoft Windows NT Server 3.5, Microsoft Windows NT Server 3.51, Microsoft Windows NT Server 4.0 Standard Edition

  • kbprb kbprogramming KB158588