Check out Scrivo

Do you want to try out Scrivo? Then here's a demo for you that does not just get your feet wet but lets you plunge right in.

Contact us

For more information, please contact us. We're happy to help you out!

Next Oct 14 Previous

Damn, when did I edit that file.

Which function can be used to set the modification date of a file?

A: stat()
B: filemtime()
C: touch()
D: None, you'll have to open the file in write mode and close it.


If you want to set the modification date of a file touch() is the function you'll want to look for. The other functions stat() and filemtime() will let you retrieve this data, not set it.

Although the approach of opening and closing actually works it is a bit cumbersome and it will not enable you to use an other time than the current system time.

So answer C is the correct answer. And if you decide to write a test program to see how touch() works I advise you to look at clearstatcache() as well: touch() will change the file time (if permitted) but most likely the new value will not directly be visible due to file caching strategies of PHP.