The ftp_mdtm() function returns the last modification time of the specified file.
This function returns the file's last modification time as a Unix timestamp, or -1 on error.
int ftp_mdtm ( resource $ftp_stream , string $remote_file )
parameter | describe |
---|---|
ftp_connection | Required. Specifies the FTP connection to log into. |
file | Required. Specifies the documents to be checked. |
Note: Not all FTP servers support this function.
<?php$file = 'somefile.txt'; // Connect to the server $conn_id = ftp_connect($ftp_server); $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // Get the best modification time $buff = ftp_mdtm($conn_id, $file);// Returns a UNIX timestamp if successful, -1 otherwise. if ($buff != -1) { // Output the last modification time of somefile.txt echo "The best modification time of $file is: " . date ("F d YH:i:s.", $buff);} else { echo "Unable to obtain the modification time of the file";}//Close the connection ftp_close($conn_id);?>