HOW TO GET: Configure FTP Server Time Zone?

I am using the PHP ftp_rawlist function to get a list of files and their recent date / time changes. For my purposes, I need to know the time zone (or offset) of the date / time that has passed the last modification. Only dates / times are useless to me, since I need to convert them to UTC.

Is there any way to find out what the FTP server time zone setting is?

+7
php utc gmt ftp
source share
5 answers

There is no way in FTP standard to determine the time zone of a remote server.

If you have write permissions to the FTP server, I think you could upload the file and then calculate the difference between the file time reported by FTP and locally.

+9
source share

Try defining your time zone at the beginning of your PHP code. Example: date_default_timezone_set ("CET"); For me, this solution worked so that it automatically converted the server time from another time zone to the desired one.

0
source share

I had the same issue recently. My approach was to create a folder in the root name / time and then read it and check the date the folders were created. Then I can set the time difference between my ftp client and server. Hope this helps.

BTW I am using https://github.com/ArxOne/FTP

// Establish a fallback var servertime = DateTime.Now; try { // query for the existance of a time folder var timefolder = ftpClient.ListEntries("/").FirstOrDefault(o => o.Name == "time"); // delete it if found if (timefolder != null) { ftpClient.Delete("/time"); } // if not found create one ftpClient.Mkd("/time"); timefolder = ftpClient.ListEntries("/").FirstOrDefault(o => o.Name == "time"); if (timefolder == null) { Logger.Fatal("Time check failed"); return; } // now grab the time of the folder. servertime = timefolder.Date; } catch (Exception x) { Logger.Fatal(x,"Time check fatal error"); return; } 
0
source share

Well, FTP does not provide local time explicitly. When write access is available, you can upload a new file and check the modification time. Without write access, you can periodically read the FTP directory and the time the notes were changed for each record. When the change time changes, you probably know the local server time. ~ 30 minutes of verification is enough, automatically, of course :)

0
source share

The time date on the files themselves already contains the time zone. The library that I use to retrieve the last modified time / date (edtFTPNet) takes into account and returns the date time converted to local system time. I would suggest that other libraries will do the same.

-3
source share

All Articles