LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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 08-17-2004, 10:41 PM   #1
antony_csf
Member
 
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.

output
================================
Last modified: January 01 1970 08:00:00

code
================================
PHP Code:
if (file_exists($fp)) {
return 
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
paulsm4
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:
<?php
  $fname 
"/tmp/tmp.txt";
  if (
file_exists($fname))
  {
     echo 
"<h2>File " $fname " exists!</h2>";
     
$d date ("F d Y H:i:s."filectime($fname));
     echo 
"d: " $d;
  }
  else
  {
     echo 
"<h2>File " $fname " doesn't exist...</h2>";
  }

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

Original Poster
Rep: Reputation: 15
got it !!
thx very much !!!
 
Old 08-18-2004, 06:46 AM   #4
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,280

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

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.

unquote
from http://iis1.cps.unizar.es/Oreilly/pe...ok/ch09_01.htm

Sorry about that ...
 
  


Reply


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


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration