Questions tagged [filemtime]

File Modification Time, also known as mtime. On a UNIX filesystem, concepts similar to mtime include atime (access time) and ctime (metadata change time).

143 questions
61
votes
6 answers

glob() - sort array of files by last modified datetime stamp

I'm trying to display an array of files in order of date (last modified). I have done this buy looping through the array and sorting it into another array, but is there an easier (more efficient) way to do this?
cole
  • 1,001
  • 2
  • 11
  • 13
42
votes
4 answers

filemtime "warning stat failed for"

I already read it so many questions and answers about it but I can't still solve my problem... I'm trying to create a function that deletes all the files with "xml" or "xsl" extension that has been created one day ago. But I'm getting this warning…
Gerard Brull
  • 1,042
  • 1
  • 9
  • 23
26
votes
11 answers

How to check if directory contents has changed with PHP?

I'm writing a photo gallery script in PHP and have a single directory where the user will store their pictures. I'm attempting to set up page caching and have the cache refresh only if the contents of the directory has changed. I thought I could…
PHLAK
  • 22,023
  • 18
  • 49
  • 52
18
votes
2 answers

Comparing dates to check for old files

I want to check if a file is older than a certain amount of time (e.g. 2 days). I managed to get the file creation time in such a way: >>> import os.path, time >>> fileCreation = os.path.getctime(filePath) >>>…
Stefano
  • 3,981
  • 8
  • 36
  • 66
17
votes
2 answers

R file.mtime() extremely poor precision on Mac OS and Windows 7

On Windows 7 and Mac OS 10.12.2 (with R 3.3.2), it appears that file.mtime() severely rounds or truncates timestamps. I verified that file.create("my_file.txt"); print(as.numeric(file.mtime("my_file.txt")), digits = 22) prints out several digits…
landau
  • 5,636
  • 1
  • 22
  • 50
16
votes
2 answers

filemtime() [function.filemtime]: stat failed for filenames with umlauts

I use the PHP function filemtime to get the last modification time with PHP 5.3. This functions works very well but it seems to have some problems when the filenames have special characters (for example umlauts). If I run it on a filename with…
Benny Code
  • 51,456
  • 28
  • 233
  • 198
14
votes
4 answers

Cost of file modification time checks

For a file containing few bytes under Linux, I need only to process when it was changed since the last time it was processed. I check whether the file was changed by calling PHP clearstatcache(); filemtime(); periodically. Since the entire file will…
doc_id
  • 1,363
  • 13
  • 41
11
votes
2 answers

Setting/changing the ctime or "Change time" attribute on a file

I wish to change the timestamp metadata on files in Java using the java.nio.Files class. I would like to change all 3 Linux/ext4 timestamps (last modified, access, and changed). I am able to change the first two timestamp fields as…
Eitan
  • 1,308
  • 3
  • 15
  • 32
11
votes
5 answers

The PHP function filemtime returning a negative value or very large value

I am creating a WordPress plugin and can see that on some servers, for certain files, the stat (or filemtime) returning invalid mtime value. In some cases it is a negative value or a very large value (more than 3 billion). In FTP I can see that the…
akshat
  • 15,472
  • 8
  • 30
  • 29
11
votes
1 answer

ctime, mtime, holding directory, windows, linux

Let's clarify this once and for all. I tried to Google this but it seems this information can't be found in one place. When a file is created or removed, the holding directory mtime changes on Windows and Linux both. ctime also changes on Linux bot…
chx
  • 11,270
  • 7
  • 55
  • 129
10
votes
1 answer

Preserve timestamp with Paramiko

Is there a way of preserving the timestamp when using Paramiko to SFTP files from one server to another similar to the -p argument in Linux? Original file: jim@vm3634:~$ ls -la -rwxrwx--- 1 jim admin 2214 Mar 30 17:33 compcip.asc Uploaded…
Jim
  • 795
  • 4
  • 13
  • 28
9
votes
5 answers

PHP file modification time in milliseconds

I there, I am currently writing a unit test which asserts that a file did not get modified. The test code execution takes less than one second and therefore I would like to know if it is possible to retrieve the file modification time in…
Steven Rosato
  • 2,174
  • 1
  • 21
  • 32
9
votes
3 answers

php clearstatcache() performance and parameters explanation

i'm using filemtime for fingerprinting external resources in html, like: I noticed a significant delay between the effective updating and the timestamp returned by…
Giona
  • 20,734
  • 4
  • 56
  • 68
8
votes
1 answer

filemtime() constant during execution despite changes to file

Try running For me the command line printed: 1343490984 1343490984 That can't be right, can it?
Woodgnome
  • 2,281
  • 5
  • 28
  • 52
4
votes
2 answers

Get filemtime for most recently updated file in folder

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?
ryanve
  • 50,076
  • 30
  • 102
  • 137
1
2 3
9 10