Wednesday, October 29, 2008

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.

Article Source

0 comments:

Your Ad Here
Reader's kind attention....The articles contained in this blog can be taken from other web sites, as the main intention of this blog is to let people get all sides of the web technologies under the single roof..so if any one finds duplication or copy of your articles in this blog and if you want that to be removed from this ..kindly inform me and i will remove it...alternatively if you want me to link back to your site with the article...that can also be done...

Thanks,
Webnology Blog Administrator
 

blogger templates