LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-05-2005, 11:38 PM   #1
airswit
Member
 
Registered: Dec 2005
Distribution: Fedora 4
Posts: 89

Rep: Reputation: 15
php: file last edited


hi, i have been looking around, and i cant seem to find any way to get the date of the last edit of a file. the reason, of course, is i would like to display on the page when the site was last updated. any help would be much appreciated!
 
Old 12-05-2005, 11:40 PM   #2
airswit
Member
 
Registered: Dec 2005
Distribution: Fedora 4
Posts: 89

Original Poster
Rep: Reputation: 15
grr...so i am retarded, not 1 minute after posting, i found my answer:

$info = stat('filename');
echo $info[9] //date of last edit!

well, while i have you here, what is the difference between last metadata change and last contents change?
 
Old 12-19-2005, 02:57 AM   #3
vireshwali
Member
 
Registered: Sep 2005
Posts: 67

Rep: Reputation: 15
following should help you easy...
PHP Code:
<?php
// outputs e.g.  somefile.txt was last modified: December 29 2002 22:16:23.

$filename 'somefile.txt';
if (
file_exists($filename)) {
   echo 
"$filename was last modified: " date ("F d Y H:i:s."filemtime($filename));
}
?>
For variations change the date function to what ever is ok to you.
Works with php3,4,5.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
edited logrotation cyberpunx Linux - Software 0 09-06-2005 01:55 PM
Open vi at top of file rather than last edited line... davee Linux - General 2 04-22-2005 06:34 AM
I edited my /etc/X11/XF86Config-4 .... AndreL Linux - Newbie 11 02-28-2004 05:13 PM
Edited Profile and Now its not booting hedbusta Linux - General 7 11-06-2002 07:43 AM
Edited times CragStar LQ Suggestions & Feedback 1 03-08-2001 10:13 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration