Re: Change the timestamp of a file on my hard drive

>Is your PC set to Toronto time (EST) or to London time (GMT / UTC)?
Yes (grin)

I'm set to (GMT-5.00) Eastern time (US & Canada).

>My PC is set to Middle European Time (GMT+1), and if I use dtOffset = -1 / 24, your code sets the file date/times correctly.
The Netherlands being one hour ahead of UTC, right? Just as I am 5 hours behind UTC.

The System Time then is using my (Control Panel) date/time settings to adjust my local time to a globally unique time. If you (in Netherlands) and I (in Toronto) save a file (in the regular manner) at the same time, for example, by agreement during a telephone dialogue, our Windows Explorer screens will show a 6-hour time difference.

But without the dtOffset patch, my code, if used by us both, would mark the saved file with an common time.

If you run my code without your dtOffset value of -1/24, then the code would use +1/24 and you would appear to be living in Athens or Beirut?

There seems to be something I've not understood here. If I release my code around the world without the dtOffset then code users who save files will see weird times appearing in the Windows Explorer screens.

Of course, my code could set the dtOffset value automatically by using the user's time zone settings, but this all seems over complicated, a double-compensation of time zones where none is needed..

Re: Change the timestamp of a file on my hard drive

>If I use your code without the offset of -1/24, the file time is set to my time + 1 hour = GMT + 2 hours (Athens, Beirut, Pretoria, ...)
Oh good. Thanks for the corroboration, and I'm sorry you had to go so far out of your way.(grin!)

So the time stamps on files are held in a global-standard system time (that's the 64-bit value), but Windows Explorer, bless its little cotton socks, carefully adjust the display so that we see the system time adjusted by our local (Control Panel) regional time offset.

If so that would mean that a VBA utility function whose job is to set the timestamp should make use of the local (Control panel) regional time offset; it is not enough to use, as an example "Now()".

Re: Change the timestamp of a file on my hard drive

Hi Chris
What libraries were necessary as references to allow this code to run in VBA. I get errors caused by at least the following: <UL><LI>FILETIME;
<LI>DateToFileTime; and
<LI> OFSTRUCT[/list]T.I.A.

Change the timestamp of a file on my hard drive

I would like to know why I get a -5 offset in time values, which I don't expect.

The attached module, borrowed from another web site, aims to change the timestamp of a file on my hard drive.
I understand the concept of a structure to manipulate a 64-bit quantity, but I'm puzzled that at noon today, without my "dtOffset" code, the timestamp changed to be 7am, as if I lived somewhere in the Pacific Ocean, two hours west of Vancouver.
I'm accustomed (in Toronto) to seeing 5pm when it's noon here; I shrug and say "OK, that's like the old UK GMT", but the Pacific Ocean ????

Re: Change the timestamp of a file on my hard drive

Hi All
I would have expected the third argument in the TESTSetFileTimesEx procedure to control the file's Accessed property, but I think that you will find it is set to coincide with the command " rtn = SetFileTime(hFile, ftCreated, ftLastAccessed, ftModified) " firing.