public function getLastModified(string $path) : DateTime
    {
        if (!$this->exists($path)) {
            throw new FileSystemException("File at path $path not found");
        }

        $modifiedTimestamp = filemtime($path);

        if ($modifiedTimestamp === false) {
            throw new FileSystemException("Failed to get last modified time of $path");
        }

        $modifiedDateTime = DateTime::createFromFormat('U', $modifiedTimestamp);

        if ($modifiedDateTime === false) {
            throw new FileSystemException('Failed to convert last modified time to DateTime object');
        }

        return $modifiedDateTime;
    }
public function getLastModified(string $path) : DateTime
    {
        if (!$this->exists($path)) {
            throw new FileSystemException("File at path $path not found");
        }

        $modifiedTimestamp = filemtime($path);

        if ($modifiedTimestamp === false) {
            throw new FileSystemException("Failed to get last modified time of $path");
        }

        $modifiedDateTime = DateTime::createFromFormat('U', $modifiedTimestamp);

        if ($modifiedDateTime === false) {
            throw new FileSystemException('Failed to convert last modified time to DateTime object');
        }

        return $modifiedDateTime;
    }
public function getLastModified ( string $ path ) : DateTime { if ( ! $ this -> exists ( $ path ) ) { throw new FileSystemException ( "File at path $path not found" ) ; } $ modifiedTimestamp = filemtime ( $ path ) ; if ( $ modifiedTimestamp === false ) { throw new FileSystemException ( "Failed to get last modified time of $path" ) ; } $ modifiedDateTime = DateTime :: createFromFormat ( 'U' , $ modifiedTimestamp ) ; if ( $ modifiedDateTime === false ) { throw new FileSystemException ( 'Failed to convert last modified time to DateTime object' ) ; } return $ modifiedDateTime ; }
Gets the last modified time

@param string $path The path to check
@return DateTime The last modified time
@throws FileSystemException Thrown if the file was not found or if the modified time was not readable
Gets the last modified time