Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> PHP

ฟังก์ชัน fileatime() ใน PHP

ฟังก์ชัน fileatime() คืนค่าเวลาที่เข้าถึงไฟล์ล่าสุด (access time) คืนค่าเป็น UNIX timestamp และคืนค่า false เมื่อล้มเหลว

Syntax

fileatime(file_path);

Parameters

  • file_path − พาธของไฟล์ที่ต้องการทราบเวลาเข้าถึงล่าสุด

Return

ฟังก์ชัน fileatime() คืนค่าเวลาเข้าถึงล่าสุดเป็น UNIX timestamp คืนค่า false เมื่อล้มเหลว

ตัวอย่างที่ 1

<?php 
   echo fileatime("new.txt"); 
?>

ผลลัพธ์

1315416291

ตัวอย่างที่ 2 (แปลงเป็นรูปแบบวันที่อ่านได้)

<?php 
   echo "Last access time of the file: ".date("F d Y H:i:s.", fileatime("new.txt")); 
?>

ผลลัพธ์

Last access time of the file: September 22 2018 11:23:52