FTP.List, FileTime and seconds lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- hebeyer · 2020-02-22 17:22 Hello, I have a little(?) problem with checking a remote file. If I want to check the date and time of a FTP-File, I use the following function: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function ftpfetchdatetime: Boolean;varaFTP: TFTPSend;i: integer;ftpdatetime: String;begin    aFTP := TFTPSend.Create;    aFTP.UserName := 'USER';  aFTP.Password := 'PASSWORD';    aFTP.TargetHost := XXX.XXXXXXXXXXXXXXXX.DE';    aFTP.TargetPort := '21';    aFTP.PassiveMode :=true;   If aFTP.Login then   begin    aftp.List('httpdocs/test.dat',false);    i := 0;    while i < aftp.FtpList.Count do      begin        ftpdatetime := DateTimeToStr(aFTP.FtpList.Items[i].FileTime);        showmessage(ftpdatetime);        i:=i+1;      end;     aftp.Logout;   aftp.Free;   end;end;       The function gives me a result of e. g. "22.02.2020 18:16:00". But: The time ist not correct. The filetime on the FTP is "18:16:37". My function always sets the seconds to "00". If I check the filetime with filezilla, it gives me the correct "18:16:37". Has everyone of you an idea, how to get the right time with seconds? Greetings from Germany Henning ---------------------------------------------------------------------- lucamar · 2020-02-22 19:09 You're using Synapse, right? It's difficult to say without seeing the whole response from the server (or at least FTPList.Items[i].OriginalLine) but most probably there is a format mismatch so that synapse can't parse the file's date/time beyond the minutes Or it may be a bug in Synapse; try to see how it's parsing the server's response. ---------------------------------------------------------------------- hebeyer · 2020-02-22 21:54 Yes. I am using synapse. FTPList.Items.OriginalLine gives me: -rw-r--r--   1 USER   psacln        305 Feb 22 17:57 httpdocs/test.dat There are also no seconds in this line  , but filezilla shows the seconds ... ---------------------------------------------------------------------- lucamar · 2020-02-23 10:00 Then either Filezilla is receiving a different format or it's inventing them Do you really need the seconds? ---------------------------------------------------------------------- Thaddy · 2020-02-23 10:40 Quote from: lucamar on February 23, 2020, 11:00:11 amThen either Filezilla is receiving a different format or it's inventing them Do you really need the seconds? How? This is not correct. The datetime is simply the creation date of the received file, so it includes seconds as well. Unless you mean the timestamp of the file on the server. That would be different, but still includes seconds. I don't think it is a bug in Synapse. I think it is merely a formatting issue. ---------------------------------------------------------------------- lucamar · 2020-02-23 11:20 Thaddy, he's referring to the FileDate as returned by the server (so yes, the timestamp of the file in the server). Synapse converts the relevant part of the response string to a TDateTime but since (according to a previous post) the server returns only "hour:minutes" in the string, it sets the seconds to zero. The thing is that Filezilla apparently gets the seconds from somewhere, hence the OP's question. Or maybe you're right and there's a confusion between the timestamp in the server and the one in the client. In fact, looking at the example's date/time along with the date/time of the original post can lead to that conclusion. Hadn't noticed before ---------------------------------------------------------------------- trev · 2020-02-23 12:28 FTP provides only limited information about a remote file. The LIST command provides an  OS-specific response where the date is usually the last modification time. The MLST/MLSD  commands provide machine- parsable responses. Whether the server returns seconds depends on the FTP server OS and the FTP server software. [It's been a while since I wrote an FTP client, like 20 years, but that's how I remember it.]