PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

filegroup> <fileatime
Last updated: Sun, 25 Nov 2007

view this page in

filectime

(PHP 4, PHP 5)

filectime — 파일의 아이노드 변경시간을 가져옵니다

Description

int filectime ( string $filename )

파일이 마지막으로 변경된 시간을 반환합니다. 에러가 발생하면 FALSE를 반환합니다. 반환되는 시간은 유닉스 형식입니다.

이 함수의 실행결과는 캐쉬가 됩니다. 좀 더 자세한 내용은 clearstatcache()를 참조하세요.

주의: 대부분의 유닉스 파일시스템에서는 아이노드의 데이타(권한, 소유자, 그룹이나 다른 요소)가 변경되었을 때 파일이 바뀌는 것이 허용됩니다. 참조: filemtime() (이것은 웹 페이지의 하단에 "마지막 수정시간"을 붙이고 싶을 때 사용합니다. ) 그리고 fileatime().

주의: 몇 몇 유닉스 텍스트에서 파일의 ctime이 파일이 만들어진 시간으로 사용하고자 하는 경우가 있는데 이것은 잘못된 것입니다. 대부분의 유닉스 파일시스템에는 파일이 만들어진 시간이라는 것이 없습니다.



filegroup> <fileatime
Last updated: Sun, 25 Nov 2007
 
add a note add a note User Contributed Notes
filectime
rich at rmbwebs dot com
11-Mar-2008 01:07
This is a modification of simraLIAS at mac dot com's code.
Modification dates should not be used for keys in an array when sorting by date because there is no guarantee that all files will have different dates.  Collisions resulting in files missing from the list could be possible.  A better way is to use the filename as the key (guaranteed to not be collisions)

<?php
foreach (glob("../downloads/*") as $path) { //configure path
   
$docs[$path] = filectime($path);
}
asort($docs); // sort by value, preserving keys

foreach ($docs as $path => $timestamp) {
    print
date("d. M. Y: ", $timestamp);
    print
'<a href="'. $path .'">'. basename($path) .'</a><br />';
}
?>
simraLIAS at mac dot com
30-Nov-2007 03:24
This is another way to get a list of files ordered by upload time:

<?php
foreach (glob("../downloads/*") as $path) { //configure path
   
$docs[filectime($path)] = $path;
}
ksort($docs); // sort by key (timestamp)

foreach ($docs as $timestamp => $path) {
    print
date("d. M. Y: ", $timestamp);
    print
'<a href="'. $path .'">'. basename($path) .'</a><br />';
}
?>
chuck dot reeves at gmail dot com
02-Oct-2007 09:14
filectime running on windows reading a file from a samba share, will still show the last modified date.
website at us dot kaspersky dot com
31-Aug-2007 10:51
Line 37 of the code above has an error.

echo  "File name: $file - Date Added: $date. <br/>""; 

There is an extra "  after the <br/> that needs to be deleted in order for this code to work.
StevieMc at example dot com
15-Nov-2006 06:28
This method gets all the files in a directory, and echoes them in the order of the date they were added (by ftp or whatever).

<?PHP
function dirList ($directory, $sortOrder){

   
//Get each file and add its details to two arrays
   
$results = array();
   
$handler = opendir($directory);
    while (
$file = readdir($handler)) { 
        if (
$file != '.' && $file != '..' && $file != "robots.txt" && $file != ".htaccess"){
           
$currentModified = filectime($directory."/".$file);
           
$file_names[] = $file;
           
$file_dates[] = $currentModified;
        }   
    }
      
closedir($handler);

   
//Sort the date array by preferred order
   
if ($sortOrder == "newestFirst"){
       
arsort($file_dates);
    }else{
       
asort($file_dates);
    }
   
   
//Match file_names array to file_dates array
   
$file_names_Array = array_keys($file_dates);
    foreach (
$file_names_Array as $idx => $name) $name=$file_names[$name];
   
$file_dates = array_merge($file_dates);
   
   
$i = 0;

   
//Loop through dates array and then echo the list
   
foreach ($file_dates as $file_dates){
       
$date = $file_dates;
       
$j = $file_names_Array[$i];
       
$file = $file_names[$j];
       
$i++;
           
        echo 
"File name: $file - Date Added: $date. <br/>"";       
    }

}
?>

I hope this is useful to somebody.
gyrbo[at]yahoo[dot]com
21-Sep-2002 04:35
filectime doesn't seem to be working properly on Win32 systems (it seems to return the creation time). Try using filemtime if you have problems.
laurent dot pireyn at wanadoo dot be
27-Sep-2001 05:01
If you use filectime with a symbolic link, you will get the change time of the file actually linked to. To get informations about the link self, use lstat.

filegroup> <fileatime
Last updated: Sun, 25 Nov 2007
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites