Page 1 of 1
File modification time on PHP<5
Posted: Mon Feb 21, 2005 5:32 am
by papieros
Hello,
I can't find a way to check remote file modification time in PHP4.
cause filemtime (stat,fstat) works on local files only, and there is
no get_headers function. I appraciate any ideas, thx.
Posted: Mon Feb 21, 2005 5:47 am
by Chris Corbyn
Remote file modification time? There are functions in PHP4 to do this using FTP if that's any help?
ftp_mdtm()
Posted: Mon Feb 21, 2005 5:54 am
by papieros
Thanks, i will look at this function but i rather need a way to get modification time via HTTP protocol.
'remote file' - I meant : 'server-side' file.
Posted: Mon Feb 21, 2005 5:56 am
by Chris Corbyn
On another server? Not localhost? I don't think http can do that... that's more of an ftp thing.
Posted: Mon Feb 21, 2005 6:12 am
by papieros
Why?, the simplest way to get 'modification-time' via http is
to get http header and examine 'Last-Modified' field.
My question could be:'how to get this header in PHP4'
(in PHP5 get_headers works fine).
Posted: Mon Feb 21, 2005 8:31 am
by feyd
Last-Modified is an optional header response.
Fsockopen and curl are often used to request a remote page to fetch the headers returned.
Posted: Mon Feb 21, 2005 10:00 am
by papieros
Last-Modified is an optional header response.
That's OK. the problem is: i want to minimize the transfer by checking
if the file was modified before the download, if there is no information
i can download it and check localy (most of the files i deal with has the
info )
Fsockopen and curl are often used to request a remote page to fetch the headers returned.
Is there no more simple way to check the header in php?, i can't believe,
but thanks anyway. (curl could be useful for other things i do)
Posted: Mon Feb 21, 2005 10:05 am
by feyd
there are no other ways to check the headers in a response outside of shelling out to a command line tool..
Posted: Tue Feb 22, 2005 3:50 am
by papieros
Hm, I wonder why? checking response header seems to be
easy to perform and important action, what's the reason for that,
anybody knows?
Posted: Tue Feb 22, 2005 8:31 am
by feyd
important, maybe.. often needed, not so much. It probably wasn't really requested until 5 was under development and 4 was probably under feature lock by that point.
Posted: Wed Aug 09, 2006 1:27 am
by anjanesh
Wanted to know regarding Last-Modified time of a http page.
Any way to figure out the remote file modification time in PHP 4 or PHP 5 ?
Server doesnt return Last-Modified always. If Last-Modified isnt returned, can we assume Date to be the Last-Modified ?
Thanks
Posted: Wed Aug 09, 2006 5:57 am
by Ollie Saunders
Does this help?
Code: Select all
echo date('F d Y H:i:s', filemtime(__FILE__));
Posted: Wed Aug 09, 2006 6:14 am
by anjanesh
Code: Select all
$url = 'http://devnetwork.net';
$LastModified = getLastModifiedTime($url);
echo $LastModified;
A get_headers($url, 1) works but many servers dont return Last-Modified time. I was wondering if theres an alternative.