ftp_mdtm() function in PHP


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

Syntax

ftp_mdtm(con,file);

Parameters

  • con − The FTP connection

  • myfile − The file to check

Return

The ftp_mdtm() function returns the last modified time as a Unix timestamp.

Example

The following is an example −

<?php
   $ftp_server="192.168.0.4";
   $ftp_user="john";
   $ftp_pass="tywg61gh";
   $con = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
   $login = ftp_login($con, $ftp_user, $ftp_pass);
   $myfile = "new.txt";
   // last modified time
   $last_modified = ftp_mdtm($ftp_conn, $file);
   if ($last_modified != -1){
      echo "$myfile was last modified on " . date("F d Y H:i:s.",$last_modified);
   } else {
      echo "Cannot get last modified!";
   }
   ftp_close($con);
?>

Updated on: 30-Jul-2019

112 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements