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!

asked 14 Apr '10, 10:14

Roger%20Porter's gravatar image

Roger Porter
161
accept rate: 0%

edited 10 Aug '10, 13:38

Rebex%20KB's gravatar image

Rebex KB ♦♦
258519


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).

link

answered 14 Apr '10, 13:05

Lukas%20Pokorny's gravatar image

Lukas Pokorny ♦♦
2.4k28
accept rate: 31%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×152
×4
×2
×1

Asked: 14 Apr '10, 10:14

Seen: 1,139 times

Last updated: 23 Mar '11, 09:22