-   Programming (
-   -   php read file creation, modified date problem (

antony_csf 08-17-2004 10:41 PM

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 !!
:confused: :confused:

paulsm4 08-18-2004 12:56 AM

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

antony_csf 08-18-2004 01:09 AM

got it !!
thx very much !!!:)

chrism01 08-18-2004 06:46 AM

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 ...

All times are GMT -5. The time now is 10:24 AM.