PHP Ftp_mdtm () function

PHP

Syntax:
ftp_mdtm ($ftp_connection, $file) 
Parameter:this function takes two parameters as specified above and described below:
  • $ftp_connection:Required. Indicates an existing FTP connection.
  • $file:Required. It points to a file or path to a file on the remote server, i.e. on the FTP server from which the last modified one will be retrieved.
Returned value:Returns the last modified time as a UNIX timestamp on success, or -1 on error .Notes :
  • This function is available for PHP 4.0.0 and newer.
  • The following examples are not can be run in the online IDE. So try running PHP on some hosting server or localhost with the correct ftp server name.
  • This function does not work for directories. All servers may not support this feature.
Example :  
// Connect to the FTP server 
// Using the correct FTP server $ftp_server = "localhost" ;  
// Use correct ftp username $ftp_username = "user" ;  
// Use correct FTP password matching
// to the ftp username $ftp_userpass = "user" ;  
// File name or path for uploading to FTP server $file = "demo_test.txt" ;  
// Setting up ftp connection $ftp_connection = ftp_connect ( $ftp_server ) or die ( "Could not connect to $ftp_server" ); if ( $ftp_connection ) { echo "successfully connected to the ftp server!" ; // Login to the established connection // ftp user password $login = ftp_login ( $ftp_connection , $ftp_username , $ftp_userpass ); if ( $login ) { // Success check login echo "< br > logged in successfully! " ; // Save the last modified data to $last_mod $last_mod = ftp_mdtm ( $ftp_connection , $file ); if ( $last_mod ! = -1) { // Check if an error occurred // when getting the last modified data echo "< br > $file was modified on " . date ( "F d YH: i: s." , $last_mod ). "." ; } else { echo "< br > could not get last modified." ; } } else { echo " < br > login failed! " ; } // Close connection if (ftp_close ( $ftp_connection )) { echo "< br > Connection closed Successfully!" ; } }
?>
Output: Link : https://www.php.net/manual/en/function.ftp-mdtm .php