Easy Tutorial
❮ Func Xml Parser Create Func Filesystem Stat ❯

PHP ftp_mdtm() Function



Definition and Usage

The ftp_mdtm() function returns the last modified time of the specified file.

This function returns the last modified time of the file as a Unix timestamp, or -1 on error.

Syntax

int ftp_mdtm ( resource $ftp_stream , string $remote_file )
Parameter Description
ftp_connection Required. Specifies the FTP connection to log in to.
file Required. Specifies the file to check.

Tips and Notes

Note: Not all FTP servers support this function.


Example

<?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 last modified time
$buff = ftp_mdtm($conn_id, $file);
// If successful, returns a Unix timestamp, otherwise returns -1.
if ($buff != -1) {
    // Output the last modified time of somefile.txt
    echo "$file last modified time is: " . date ("F d Y H:i:s.", $buff);
} else {
    echo "Could not get the modification time of the file";
}

// Close the connection
ftp_close($conn_id);
?>

❮ Func Xml Parser Create Func Filesystem Stat ❯