Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[PHP]Aktuellstes Dateidatum

Empfohlene Antworten

Veröffentlicht

Mahlzeit,

ich habe ein Skript geschrieben, welches dazu dient, in einer Galerie anzuzeigen, wann das letzte mal Bilder hinzugekommen sind.

<?
$handle=opendir('.');
$data = array();
while ($file = readdir ($handle))
{
if ($file != "." && $file != "..")
{
$filedate = filemtime($file);
}
}

closedir($handle);
natsort($data);
$data = array_reverse($data);
$date = date("d.m.Y", $filedate);
echo "<font size='1' face='Verdana'> Letztes Bild vom $date</font>";

?>
[/PHP]

Es läuft auch ganz wunderbar, ohne Probleme. Lege ich die Datei nun jedoch nicht im Bilderordner ab, sondern bspw. im Root-Ordner der Galerie, und ändere ich den entsprechenden Opendir Pfad, so bekomm ich stets nur noch den 1.1.1970 angezeigt. Kann mir jemand sagen wo sich der Fehler verbirgt? Ich sehe ihn nicht :(

anscheinend passt dein Opendir nicht...

Ausserdem würde ich das anders lösen, da das auslesen von großen Ordnern sehr lange dauern kann...

Offenbar kümmern dich Subdirectories nicht. Dann reicht es die filemtime auszugeben.

To get the last modification time of a directory, you can use this:

$getLastModDir = filemtime("/path/to/directory/.");

Take note on the last dot which is needed to see the directory as a file and to actually get a last modification date of it.

Aber:

"When using this function to get the modified date of a directory,

it returns the date of the file in that directory that was last modified."

this is not (necessarily) correct, the modification time of a directory will be the time of the last file *creation* in a directory (and not in it's sub directories).

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.