I am referring the documentation of
Epoch timestamp 1477027260 as shown in the image above.
But I get the time_write as 1477043509
To troubleshoot further, next I used GetFileTime API to retrieve the the file modification time in FILETIME struct and converted the time into UTC timestamp. I got the time according the time set on my computer. I was expecting the same.
At this point I started investigating the way we execute our program through a perl script. I found that perl script was setting the timezone to
Since my computer was in timezone
GMT+5:30, therefore I used to get resultant
+04:30 hrs of difference as mentioned in the original post.
Therefore I would like to sum up my experience as - the outcome of
_finddata_t strcut is affected by the timezone set in the session but the outcome of
FILETIME struct is not affected by the time zone set in the session, instead it is the time according the system timezone. Since I was retrieving one time using
FILETIME struct and another using
_finddata_t strcut that was causing the problem. Took me ~48Hrs to find out this interesting observation.
Why does that happen? Perhaps the answer is provided by Harry in the comment section.I am pasting the same here as it is -
changing the timezone in Perl is probably causing the TZ environment variable to be set, which affects the C runtime library as per the documentation for _tzset. It isn't a per-session setting, at least not in the way Windows uses the word "session"."