The Wayback Machine - https://web.archive.org/web/20231211193744/https://www.geeksforgeeks.org/php-filectime-function/
Open In App
Related Articles

PHP | filectime( ) Function

Improve Article
Improve
Save Article
Save
Like Article
Like

The filectime() function in PHP is an inbuilt function which is used to return the last time the specified file was changed. The filectime() function returns the last time the file was changed as a Unix Timestamp on success and False on failure. The filectime() function checks for inode changes which are the updations in permissions, owner, group or other metadata as well as regular changes.

The filename is passed as a parameter to the filectime() function. The result of the filectime() function is cached and a function called clearstatcache() is used to clear the cache.

Syntax:

filectime($filename)

Parameters: The filectime() function in PHP accepts only one parameter $filename. It specifies the file whose last changed time you want to check.

Return Value: It returns the last changed time of a file as a Unix Timestamp on success and False on failure.

Errors And Exception:

  1. The time resolution may differ from one file system to another.
  2. This function doesn’t works on some unix systems which have access time updates are disabled to increase performance.

Examples:

Input : echo filectime("gfg.txt");
Output : 1525159574

Input : echo "Last changed: ".date("F d Y H:i:s.", 
                            filectime("gfg.txt"));
Output : Last changed: May 1 2018 07:26:14.

Below programs illustrate the filectime() function.

Program 1:




<?php
  
// checking last time a file was changed
echo filectime("gfg.txt");
  
?>


Output:

1525159574

Program 2:




<?php
  
// checking last time a file was changed
echo filectime("gfg.txt");
  
// checking last time a file was changed
// and formatting the output of the date 
echo "Last changed: ".date("F d Y H:i:s.", 
                    filectime("gfg.txt"));
?>


Output:

1525159574
Last changed: May 1 2018 07:26:14.

Reference:
http://php.net/manual/en/function.filectime.php

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 03 May, 2018
Like Article
Save Article
Previous
Next
Similar Reads
Complete Tutorials