PHP: Hypertext Preprocessor (2024)

(PHP 4, PHP 5, PHP 7, PHP 8)

filectimeLiefert die Änderungszeit eines Datei-Inodes

Beschreibung

filectime(string $filename): int|false

Gibt die Zeit der letzten Änderung eines Datei-Inodes zurück.

Parameter-Liste

filename

Pfad zu der Datei.

Rückgabewerte

Gibt die Zeit der letzten Änderung einer Datei zurück. Bei einem Fehler wird false zurückgegeben. Die Zeit wird als UNIX-Zeitstempel zurückgegeben.

Fehler/Exceptions

Im Fehlerfall wird eine E_WARNING ausgegeben.

Beispiele

Beispiel #1 filectime()-Beispiel

<?php// Ausgabe z. B. somefile.txt wurde zuletzt geändert: December 29 2002 22:16:23.$filename = 'somefile.txt';
if (
file_exists($filename)) {
echo
"$filename wurde zuletzt geändert: " . date("F d Y H:i:s.", filectime($filename));
}
?>

Anmerkungen

Hinweis:

Anmerkung: Bei den meisten Unix-Dateisystemen gilt eine Datei als geändert, sobald ihre Inode-Daten geändert wurden; d.h. wenn die Berechtigungen, Eigentümer, Gruppe oder andere Metadaten des Inodes aktualisiert werden. Siehe auch filemtime() (was man verwenden sollte, um Fußzeilen mit "Zuletzt Aktualisiert" für Webseiten zu erstellen) und fileatime().

Hinweis:

Es ist auch zu beachten, dass in einigen Unix-Texten ctime als die Zeit der Erstellung der Datei beschrieben wird. Das ist falsch. Bei den meisten Unix-Dateisystemen gibt es keine Zeitangabe für die Erstellung von Unix-Dateien.

Hinweis:

Beachten Sie, dass die zeitlicheAuflösung bei verschiedenen Dateisystemen unterschiedlich sein kann.

Hinweis: Die Ergebnisse dieser Funktionwerden zwischengespeichert. Weitere Details sind beiclearstatcache() zu finden.

Tipp

Seit PHP 5.0.0 kann dieseFunktion mit einigen URL-Wrappern benutzt werden. SchauenSie in der Liste unter Unterstützte Protokolle und Wrapper nach, welcher Wrapper dieFunktionalität von stat() unterstützt.

Siehe auch

  • filemtime() - Liefert die Zeit der letzten Dateiänderung

up

down

15

StevieMc at example dot com

17 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

down

3

faketruth at yandex dot ru

9 years ago

If you need file creation time on Mac OS X:

<?php
if ($handle = popen('stat -f %B ' . escapeshellarg($filename), 'r')) {
$btime = trim(fread($handle, 100));
echo
strftime("btime: %Y.%m.%d %H:%M:%S\n", $btime);
pclose($handle);
}
?>

up

down

3

javi at live dot com

15 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

down

2

coolkoon at gmail dot com

13 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

down

1

website at us dot kaspersky dot com

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

up

down

1

m dot rabe at directbox dot com

14 years ago

Under Windows you can use fileatime() instead of filectime().

up

down

1

chuck dot reeves at gmail dot com

16 years ago

filectime running on windows reading a file from a samba share, will still show the last modified date.

up

down

soapergem at gmail dot com

14 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

down

-1

laurent dot pireyn at wanadoo dot be

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

+add a note

PHP: Hypertext Preprocessor (2024)

References

Top Articles
2024 U-Haul Truck Rental Review | Move.org
Moon Knight: Fist Of Khonshu #0 In Stores Today... Well Some Stores
Joi Databas
Somboun Asian Market
Cottonwood Vet Ottawa Ks
Identifont Upload
COLA Takes Effect With Sept. 30 Benefit Payment
Alan Miller Jewelers Oregon Ohio
Exam With A Social Studies Section Crossword
Clafi Arab
Riegler &amp; Partner Holding GmbH auf LinkedIn: Wie schätzen Sie die Entwicklung der Wohnraumschaffung und Bauwirtschaft…
12 Best Craigslist Apps for Android and iOS (2024)
Socket Exception Dunkin
Oro probablemente a duna Playa e nomber Oranjestad un 200 aña pasa, pero Playa su historia ta bay hopi mas aña atras
Craiglist Galveston
Elemental Showtimes Near Cinemark Flint West 14
U Arizona Phonebook
Invitation Homes plans to spend $1 billion buying houses in an already overheated market. Here's its presentation to investors setting out its playbook.
Parc Soleil Drowning
Tips and Walkthrough: Candy Crush Level 9795
Thick Ebony Trans
MyCase Pricing | Start Your 10-Day Free Trial Today
Walgreens On Bingle And Long Point
How do you get noble pursuit?
Sandals Travel Agent Login
Log in or sign up to view
Nurofen 400mg Tabletten (24 stuks) | De Online Drogist
Mosley Lane Candles
Perry Inhofe Mansion
Earthy Fuel Crossword
Grove City Craigslist Pets
Best New England Boarding Schools
2430 Research Parkway
Http://N14.Ultipro.com
Forager How-to Get Archaeology Items - Dino Egg, Anchor, Fossil, Frozen Relic, Frozen Squid, Kapala, Lava Eel, and More!
Barrage Enhancement Lost Ark
Wildfangs Springfield
Shoreone Insurance A.m. Best Rating
Wsbtv Fish And Game Report
Craigslist Gigs Wichita Ks
Elisabeth Shue breaks silence about her top-secret 'Cobra Kai' appearance
Pokemon Reborn Locations
Mid America Irish Dance Voy
Nba Props Covers
Torrid Rn Number Lookup
Wgu Admissions Login
Devotion Showtimes Near Showplace Icon At Valley Fair
Windy Bee Favor
Identogo Manahawkin
Steam Input Per Game Setting
Bob Wright Yukon Accident
Latest Posts
Article information

Author: Clemencia Bogisich Ret

Last Updated:

Views: 5916

Rating: 5 / 5 (80 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Clemencia Bogisich Ret

Birthday: 2001-07-17

Address: Suite 794 53887 Geri Spring, West Cristentown, KY 54855

Phone: +5934435460663

Job: Central Hospitality Director

Hobby: Yoga, Electronics, Rafting, Lockpicking, Inline skating, Puzzles, scrapbook

Introduction: My name is Clemencia Bogisich Ret, I am a super, outstanding, graceful, friendly, vast, comfortable, agreeable person who loves writing and wants to share my knowledge and understanding with you.