DirectoryIterator::getATime

(PHP 5, PHP 7, PHP 8)

DirectoryIterator::getATimeObtener el último acceso del elemento actual DirectoryIterator

Descripción

public DirectoryIterator::getATime(): int

Obtiene el último acceso del elemento actual DirectoryIterator.

Parámetros

Esta función no tiene parámetros.

Valores devueltos

Devuelve la hora del último acceso al fichero, en formato Unix timestamp.

Ejemplos

Ejemplo #1 Ejemplo de DirectoryIterator::getATime()

Muestra una lista de los ficheros en el directorio del script y los últimos tiempos de acceso.

<?php
$iterator 
= new DirectoryIterator(dirname(__FILE__));
foreach (
$iterator as $fileinfo) {
    if (
$fileinfo->isFile()) {
        echo 
$fileinfo->getFilename() . " " $fileinfo->getATime() . "\n";
    }
}
?>

El resultado del ejemplo sería algo similar a:

manzana.jpg 1240047118
banana.jpg 1240065176
index.php 1240047208
pera.jpg 12240047979

Ver también

add a note add a note

User Contributed Notes 1 note

up
0
petweb at quaint dot info
15 years ago
Note that, as with filetime, the returned value is a Unix timestamp. So it can be used with the date() function;

date ("F d Y H:i:s.", filemtime($file->getATime()));
To Top