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

search for in the

filegroup> <fileatime
[edit] Last updated: Fri, 24 May 2013

view this page in

filectime

(PHP 4, PHP 5)

filectimeDosyanın dosya düğümü değişiklik zamanını döndürür

Açıklama

int filectime ( string $dosyaismi )

Belirtilen dosyanın dosya düğümü değişiklik zamanını döndürür.

Değiştirgeler

dosyaismi

Dosya yolu.

Dönen Değerler

Belirtilen dosyanın son dosya düğümü değişiklik zamanını döndürür. Hata durumunda FALSE döner. Zaman bir Unix zaman damgası olarak döndürülür.

Örnekler

Örnek 1 - filectime() örneği

<?php
// Çıktı şöyle bir şey olur:
// birdosya.txt dosyasının son değişiklik zamanı: December 29 2008 22:16:23.

$dosya 'birdosya.txt';
if (
file_exists($dosya)) {
    echo 
"$dosya dosyasının son değişiklik zamanı: " .
          
date ("F d Y H:i:s."filectime($dosya));
}
?>

Notlar

Bilginize:

Çoğu Unix dosya sisteminde dosya düğümü verisi değiştiğinde, yani, dosya izinleri, dosyanın sahibi veya grubu ya da diğer temel verileri değiştiğinde dosya değişmiş sayılır. Ayrıca, (sitenizin son güncellendiği tarihi belirtmek isterseniz) filemtime() ve fileatime() işlevlerine de bakınız.

Bilginize:

Bazı Unix belgelerinde bir dosyanın dosya düğümü değişiklik zamanı dosyanın oluşturuluş zamanı olarak gösterilir. Bu yanlıştır. Çoğu Unix dosya sisteminde Unix dosyaları için bir oluşturulma zamanı mevcut değildir.

Bilginize:

Zaman çözünürlüğünün dosya sistemine göre farklı olabileceğini unutmayın.

Bilginize: Bu işlevin sonuçları önbelleğe kaydedilir. Daha ayrıntılı bilgi edinmek için clearstatcache() işlevine bakınız.

İpucu

PHP 5.0.0 sürümünden itibaren bu işlev bazı URL sarmalayıcıları ile kullanılabilmektedir. stat() ailesini destekleyen sarmalayıcıların listesini Supported Protocols and Wrappers başlığı altında bulabilirsiniz.

Ayrıca Bakınız

  • filemtime() - Dosyanın değişiklik zamanını döndürür



filegroup> <fileatime
[edit] Last updated: Fri, 24 May 2013
 
add a note add a note User Contributed Notes filectime - [11 notes]
up
3
StevieMc at example dot com
6 years ago
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.
up
2
coolkoon at gmail dot com
2 years ago
You should avoid feeding the function files without a path. This applies for filemtime() and possibly fileatime() as well. If you omit the path the command will fail with the warning "filectime(): stat failed for filename.php".
up
1
laurent dot pireyn at wanadoo dot be
11 years ago
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.
up
1
chuck dot reeves at gmail dot com
5 years ago
filectime running on windows reading a file from a samba share, will still show the last modified date.
up
-1
simraLIAS at mac dot com
5 years ago
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 />';
}
?>
up
0
m dot rabe at directbox dot com
3 years ago
Under Windows you can use fileatime() instead of filectime().
up
0
soapergem at gmail dot com
3 years ago
Note that on Windows systems, filectime will show the file creation time, as there is no such thing as "change time" in Windows.
up
0
javi at live dot com
4 years ago
Filemtime seems to return the date of the EARLIEST modified file inside a folder, so this is a recursive function to return the date of the LAST (most recently) modified file inside a folder.

<?php

// Only take into account those files whose extensions you want to show.
$allowedExtensions = array(
 
'zip',
 
'rar',
 
'pdf',
 
'txt'
);

function
filemtime_r($path)
{
    global
$allowedExtensions;
   
    if (!
file_exists($path))
        return
0;
   
   
$extension = end(explode(".", $path));    
    if (
is_file($path) && in_array($extension, $allowedExtensions))
        return
filemtime($path);
   
$ret = 0;
   
     foreach (
glob($path."/*") as $fn)
     {
        if (
filemtime_r($fn) > $ret)
           
$ret = filemtime_r($fn);   
           
// This will return a timestamp, you will have to use date().
    
}
    return
$ret;   
}

?>
up
-1
gyrbo[at]yahoo[dot]com
10 years ago
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.
up
-2
rich at rmbwebs dot com
5 years ago
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 />';
}
?>
up
-2
website at us dot kaspersky dot com
5 years ago
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.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites