Get filemtime for most recently updated file in folder

后端 未结 2 1962
孤城傲影
孤城傲影 2021-01-01 04:21

I have a folder with 4 files in it and I\'d like to pull the last modified time of the most recent one (which may not always be the same one). Is there a good way to do that

2条回答
  •  清酒与你
    2021-01-01 05:11

    There is no need to iterate through the directory - filemtime will work for most servers, (depending on your configuration):

    $LastMod = filemtime("/path/to/dir/.");
    

    The last dot is needed to see the directory as a file and to actually get a last modification date of it.

提交回复
热议问题