filemtime() function in PHP


The filemtime() function returns the last modification time of a file. It returns the last modification time of a file as a UNIX timestamp and returns false on failure.

Syntax

filemtime ( file_path );

Parameters

  • file_path − The path of the file for which the last modification time will be found.

Return

The filemtime() function returns the last modification time of a file as a UNIX timestamp and returns false on failure.

Example

<?php
   echo filemtime("info.txt");
?>

Output

16127342863

Let us now get the last modification time of a file as a date which is in human readable form.

Example

 Live Demo

<?php
   echo "Last modification time of the file: ".date("F d Y H:i:s.",filectime("info.txt"));
?>

Output

Last modification time of the file: September 24 2018 07:55:51

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 24-Jun-2020

822 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements