So I'm trying to get the file's last modified date and then update it to the current time, but when I look at the result I get the SAME timestamp in both $oldtime and $newtime
$file = 'test.txt';
$oldtime = filemtime($file);
touch($file, time());
$newtime = filemtime($file);
echo '<h1>old</h1>';
print_r(getdate($oldtime));
echo '<h1>new</h1>';
print_r(getdate($newtime));
Use clearstatcache
after touch
ing file to get proper value of modification time.
Because you have used filemtime
before, result for it was cached, and on second call, result is pulled from that cache instead of checking file directly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With