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));
touching 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.