0 votes
by (120 points)
edited

I am using GetFileDateTime to get the remote datetimemodified but it is returning one hour less than what is on the server, why?

Thanks for any help,

Jiggy!

Applies to: Rebex FTP/SSL, Rebex Time

1 Answer

0 votes
by (147k points)
edited

The problem with GetFileDateTime is that some servers use local time zone while others use UTC/GMT time zone in their response to MDTM command (used by GetFileDateTime method). For this reason, we return the DateTime value with the Kind property of DateTimeKind.Unspecified – it's either UTC or local time.

If "British Summer Time" (UTC+1) is the server's current time zone and its MDTM command returns UTC datetime values, then the time returned by GetFileDateTime will be one hour less than what the current local server time is. During winter, the time returned will match the local time - this won't be true for users in other countries, of course.

To convert the value returned by GetFileDateTime from UTC time to local time, use DateTime's ToLocalTime method.

Of course, this must only be done for FTP servers that use UTC time zone in its MDTM replies. On FTP servers that use local time, doing this would result in wrong time again. This situation is unfortunate, but hard to solve (FTP protocol offers no way to determine server's time zone or current time and although there are some ways to detect these, none of them is reliable enough and most of them involve uploading a temporary file at the FTP server).

...