File Modification Time, also known as mtime. On a UNIX filesystem, concepts similar to mtime include atime (access time) and ctime (metadata change time).
Questions tagged [filemtime]
143 questions
4
votes
2 answers
Cache Busting images inside CSS
My situation
I am currently using Cache Busting when I include CSS files like this:
echo "<link href='stylesheet.css?" . filemtime('stylesheet.css') . "' />"
My goal
Now I would like to do something similar for the images I am including inside my…

Michiel Pater
- 22,377
- 5
- 43
- 57
4
votes
1 answer
Trying to add versioning using filemtime but fail
On a wordpress environment.
I'm trying to automatically add versioning to my scripts using filemtime, but get the following error message:
Warning: filemtime() [function.filemtime]: stat failed for (file name)
the code is simple
$myfile =…

nonhocapito
- 466
- 5
- 18
4
votes
2 answers
filemtime returns same value before and after modification of file
Im trying to get the last modified time of a file before and after i write to it using fwrite. But, i get the same values for some reason.
";
$e=fopen('log.txt', 'w');
fwrite($e,…

Haider Ali
- 918
- 2
- 9
- 26
4
votes
2 answers
Sorting files with filemtime() and usort() gives random results
I'm using usort() and filemtime() to sort files by modification date, but it randomly returns files in the wrong order. I guess I'm missing something really simple but I can't figure out what.
usort($user_files, function($a, $b) {
return…

Alex
- 1,416
- 4
- 16
- 42
4
votes
3 answers
filemtime not finding files
I'm trying to get the date and time of the last modification of some files using filemtime. Unfortunately, this is failing for all of my files. I've tried using the full, complete path (e.g. www.mysite.com/images/file.png). I've tried just using the…

AndroidDev
- 20,466
- 42
- 148
- 239
4
votes
1 answer
Get last modified file time dynamically
I've made a few unsuccessful attempts. I want to get the last modified file time, by current file - i.e. the file currently being viewed. The following code works for the employer.es.php file, but I reuse this in other files unless I keep changing…

gstricklind
- 464
- 2
- 6
- 17
4
votes
2 answers
Why is my core file not overwritten?
On Ubuntu 12.04, open a new text file and write:
#include
int main()
{
abort();
return 0;
}
Now run:
g++ yourfile.cpp
Then run the executable, which will core dump:
./a.out
Now check the mtime of the file:
-rw-r----- 1 xxxxx…

Joseph Garvin
- 20,727
- 18
- 94
- 165
3
votes
1 answer
PHP Recursively File Folder Scan Sorted by Modification Date
I'm using this script to see all subfolders and files of subfolders
function readfolder($dir)
{
global $tfile,$tdir;$i=0;$j=0;$myfiles;
$myfiles[][] = array();
if (is_dir($dir)) {
if ($dh = opendir($dir))…

Goldie
- 1,570
- 5
- 21
- 33
3
votes
3 answers
PHP filemtime vs MySQL last updated timestamp for image caching in CMS
I'm trying to determine if it's better to store an image's last modified date in a MySQL database or use the PHP function filemtime.
In my case, all of the website info is stored in a database (cms), so there is always a query to pull the image…

drooh
- 578
- 4
- 18
- 46
3
votes
2 answers
difference between fileatime and filectime in php
In php manual fileatime is defined as 'last access time of a file'.But in my code ,i opened and read the file content.But fileatime gives me a date back to february 16.Which means i last accessed the file in february 16 ??.But i accessed the file…

AL-zami
- 8,902
- 15
- 71
- 130
3
votes
1 answer
How to sort by mtime a given list of files in Python3?
I am trying to do a function which receives a list of files (absolute paths) and returns the list sorted by the mtime of the files. Note that the argument is a list of files, not a directory path.
Anyone can help me? Thank you in…

forvas
- 9,801
- 7
- 62
- 158
3
votes
2 answers
FTP: Can I overwrite a file and maintain it's modified date?
I have hundreds of mp3 files on my server. Each file's modified-date is important because it is fetched by PHPs filemtime to represent it's upload date (since there's no way to determine an upload time without storing values in a database).
I have…

Snailer
- 3,777
- 3
- 35
- 46
2
votes
2 answers
Detect mtime resolution of filesystem
How do I find out what the mtime resolution of a system is from Node.js?
Why I'm asking
In Node.js, fs.watch will sometimes emit duplicate change events. In order to avoid taking redundant actions, it's common to use code like this (from…

Trevor Burnham
- 76,828
- 33
- 160
- 196
2
votes
2 answers
Order this array by date modified?
I have a php file that is creating a array of everything in my users directory, the array is then being sent back to a iPhone.
The array that my php is creating is ordering them alphabetically, i want it to sort by the date the file was…

Jacob
- 1,459
- 2
- 19
- 32
2
votes
4 answers
How to get the content of a file when it changes in PHP
I am fairly new to php.
I have a text file on my computer which changes the content frequently. I want to get the content of the file as soon as it is changed and insert it to an html form.
I wanted to use the filemtime function on php but I didn't…

Momo
- 523
- 3
- 11
- 23