PHP | DirectoryIterator getCTime() Function
Last Updated :
07 Mar, 2024
The DirectoryIterator::getCTime() function is an inbuilt function in PHP which is used to get the inode change time of the current DirectoryIterator item.
Syntax:
int DirectoryIterator::getCTime( void )
Parameters: This function does not accept any parameters.
Return Value: This function returns the last change time of the file in Unix timestamp format.
Below programs illustrate the DirectoryIterator::getCTime() function in PHP:
Program 1:
<?php
$directory = new DirectoryIterator(dirname( __FILE__ ));
while ( $directory ->valid()) {
if ( $directory ->isDir()) {
$file = $directory ->current();
echo $file ->getFilename() . " | CTime: "
. $directory ->getCTime() . "<br>" ;
}
$directory ->next();
}
?>
|
Output:
. | CTime: 1574350718
.. | CTime: 1574350715
dashboard | CTime: 1574350718
img | CTime: 1574350718
webalizer | CTime: 1574350718
xampp | CTime: 1574350718
Program 2:
<?php
$directory = new DirectoryIterator(dirname( __FILE__ ));
foreach ( $directory as $dir ) {
$file = $directory ->current();
echo $dir ->key() . " => " .
$file ->getFilename() . " | CTime: " .
$dir ->getCTime() . "<br>" ;
}
?>
|
Output:
0 => . | CTime: 1574350718
1 => .. | CTime: 1574350715
2 => applications.html | CTime: 1574350724
3 => bitnami.css | CTime: 1574350724
4 => dashboard | CTime: 1574350718
5 => favicon.ico | CTime: 1574350724
6 => geeks.PNG | CTime: 1574478578
7 => gfg.php | CTime: 1574351394
8 => img | CTime: 1574350718
9 => index.php | CTime: 1574350723
10 => webalizer | CTime: 1574350718
11 => xampp | CTime: 1574350718
Note: The output of this function depends on the content of server folder.
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...