Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 08-17-2004, 10:41 PM   #1
Registered: Jun 2004
Posts: 51

Rep: Reputation: 15
php read file creation, modified date problem

I have try to get the file creation date, but the outcome is not my expectation.

Last modified: January 01 1970 08:00:00

PHP Code:
if (file_exists($fp)) {
date ("F d Y H:i:s."filectime($filename));

what is the problem?
anyone can help me
thx !!
Old 08-18-2004, 12:56 AM   #2
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Is "$filename" correctly initialized?

Hi -

1. The reason you're seeing "Jan 1, 1970" is because you're passing in a date value of "0".

2. I'm guessing this is probably because "$filename" wasn't initialized correctly, in which case "filectime()" will return "0" and pass it to "date()".

3. Outside of that, your code appears fine. Here's a sample that runs fine (it prints out "found" and the correct date if test file "/tmp/tmp.txt" exists; it prints out "not found" if it doesn't):

PHP Code:
  if (
"<h2>File " $fname " exists!</h2>";
$d date ("F d Y H:i:s."filectime($fname));
"d: " $d;
"<h2>File " $fname " doesn't exist...</h2>";

'Hope that helps .. PSM
Old 08-18-2004, 01:09 AM   #3
Registered: Jun 2004
Posts: 51

Original Poster
Rep: Reputation: 15
got it !!
thx very much !!!
Old 08-18-2004, 06:46 AM   #4
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 17,735

Rep: Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523
Hate to ruin your day, buy you can't get the file creation time...

Three fields in the inode structure contain the last access, change, and modification times: atime, ctime, and mtime. The atime field is updated each time the pointer to the file's data blocks is followed and the file's data is read. The mtime field is updated each time the file's data changes. The ctime field is updated each time the file's inode changes. The ctime is NOT creation time; there is no way under standard Unix to find a file's creation time.


Sorry about that ...


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
nautilus: changing the appearance of the 'date modified' column? apeekaboo Linux - Software 1 09-23-2011 03:36 AM
ls -al file creation date blackzone Linux - Newbie 2 08-23-2004 01:31 AM
remove 'modified date' column in nautilus list view nexx_au Linux - Software 0 12-09-2003 03:29 AM
Where can I look for the config file for modified date and time ForumKid Linux - General 1 09-19-2003 08:05 AM
creation date of file using the 'ls' command robt Linux - Newbie 1 03-27-2003 12:34 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:25 PM.

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