does anyone know how i can use php to check the age of a file
I have simple bit of code that downloads rss feed to my local host, but I only want it to run if
1. the downloaded file doesnt exist
2. the downloaded file is more than say 2 hours old
php to check age of a file
Moderator: General Moderators
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
I don't know of a function to check creation time, but last modification time can be accessed using , if a file exists use
Code: Select all
filemtime()Code: Select all
file_exists()What operating system you are using?
If Linux / Unix, then
information can not be get. The kernel only stores three different times:
atime
Time of last access as seconds since Epoch
mtime
Time of last modification as seconds since Epoch
ctime
Time of last change as seconds since Epoch
man stat or see /usr/include/linux/stat.h
If Linux / Unix, then
information can not be get. The kernel only stores three different times:
atime
Time of last access as seconds since Epoch
mtime
Time of last modification as seconds since Epoch
ctime
Time of last change as seconds since Epoch
man stat or see /usr/include/linux/stat.h
Thanks JAY that helped
possibly unix, but mtime seemed to work for me
I used :
all seems to work, obviously this wont work very well if ppl only use it once every 24hrs (difference will be 0), but expect the page to be looked at at least once every few hours.
Is there a way around since i want to release this as free ware (im new to php), eg convert date to absolute seconds
possibly unix, but mtime seemed to work for me
I used :
Code: Select all
if ( (date('h') - date('h', filemtime("TempRSSFeed.txt")) ) > x) { // then do codeIs there a way around since i want to release this as free ware (im new to php), eg convert date to absolute seconds