Example 1 — Show When a Remote File Changed
Read the modification time of a file and print it as a readable date.
<?php
$ftp = ftp_connect('ftp.example.com');
ftp_login($ftp, 'username', 'password');
$time = ftp_mdtm($ftp, 'report.txt');
echo "Last modified: ", date('Y-m-d H:i:s', $time), PHP_EOL;
ftp_close($ftp); How It Works
- The script connects and logs in with placeholder credentials.
- ftp_mdtm() asks the server for the modified time of report. txt.
- The server answers with a Unix timestamp.
- date() converts that number into a year-month-day format.

