फ़ंक्शन fileatime
फ़ंक्शन fileatime यूनिक्स टाइमस्टैम्प के रूप में फ़ाइल की अंतिम पहुंच का समय लौटाता है। पैरामीटर के रूप में फ़ाइल का पथ पास किया जाता है। यदि फ़ाइल मौजूद नहीं है, तो फ़ंक्शन false लौटाएगा।
वाक्य - विन्यास
fileatime(string $filename): int|false
उदाहरण
फ़ाइल की अंतिम पहुंच का समय प्राप्त करें:
<?php
$res = fileatime('test.txt');
echo $res;
?>
कोड निष्पादन का परिणाम:
1672531200
उदाहरण
पहुंच समय प्राप्त करने से पहले फ़ाइल के अस्तित्व की जांच करें:
<?php
$filename = 'nonexistent.txt';
if (file_exists($filename)) {
echo fileatime($filename);
} else {
echo 'File not found';
}
?>
कोड निष्पादन का परिणाम:
'File not found'
उदाहरण
यूनिक्स टाइमस्टैम्प को पठनीय प्रारूप में बदलें:
<?php
$timestamp = fileatime('test.txt');
echo date('Y-m-d H:i:s', $timestamp);
?>
कोड निष्पादन का परिणाम:
'2023-01-01 00:00:00'