Use this snippet to modify the access and modification times of a file on the server
<? // $ptf: absolute path to the file // $str_date: the date to set it to i.e. (23 November 2008 22:30:10) function set_file_mod_time($ptf, $str_date) { return touch($ptf, strtotime($str_date)); } ?>
This sets the access and modification times of a file on the server.
Returns true or false.
So call it like:
<pre>
if (!set_file_mod_time('/home/user/public_html/file.txt', '23 November 2008 22:30:10'))
{
echo 'Something went wrong';
}
else
{
echo 'Modified time changed!';
}
</pre>
Of course the pitfall is that the process must own the file. On a plain environment
it should be nobody or www the file owner.
Comments
guest
Posted on 25.12.2008 06:50
thanks, got it!
Add your comment