Wrapped the above in a function, for easy use:
function getMtime($filename, $server, $login, $pwd){
// set up connection
$conn_id = ftp_connect($server) or die("ERROR:Could not connect to $server");
// login
$login_result = ftp_login($conn_id, $login, $pwd);
// get the last modified time for our file
$buff = ftp_mdtm($conn_id, $filename);
// close the connection
ftp_close($conn_id);
if ($buff != -1) {
// somefile.txt was last modified on: March 26 2003 14:16:41.
return "$filename was last modified on : " . date("F d Y H:i:s.", $buff);
} else {
return "ERROR: Could not retrieve mdtime";
}
}
$filename='example.csv';
$server='ftp.example.nl';
$login='supersecureloginhere';
$pwd='supersecurepwd';
$mtime=getMtime($filename, $server, $login, $pwd);
echo $mtime;