SQL PHP HTML ASP JavaScript articles and free scripts to download
PHP File Function

Getting the last updated time of the file in PHP

We can get the last updated date of any file by using filemtime function in PHP. This function returns date in UNIX Timestamp format and we can convert it to our requirement by using date function.

This function filemtime() uses the server file system so it works for local systems only, we can't use this function to get the modified time of any remote file system.

Here is the code to get the last modified date of any file. We are checking for a existing file ( test.php)
echo date("m/d/Y",filemtime(“test.php”));
The above code will display the modified date in month/day/year format.
Note that we have used date function to convert the Unix Timestamp time returned by filemtime() function.
$file = $_SERVER["SCRIPT_NAME"];
    $break = Explode('/', $file);
    $pfile = $break[count($break) - 1]; 
//echo $pfile;
echo "This file was last modified on: " .date("d/m/Y",filemtime($pfile));

Be the first to post comment on this article :


Google+
Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked



Join Our Email List
Email:  
For Email Newsletters you can trust
HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer