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
1
vote
1 answer

How to get filemtime compared to current time

I need to check the last modified time of my file. I have used filemtime() in PHP for that as below..
This works fine and I…
Codec737
  • 117
  • 6
1
vote
1 answer

Get the mtime of a symlink and not its target in Python

In Python (and Python2) on macOS, when I use os.path.getmtime('/path/to/a/symlink') I get the modification time of the symlink's target. - How do I get instead the modification time of the symlink itself?
halloleo
  • 9,216
  • 13
  • 64
  • 122
1
vote
1 answer

File seems to be timestamped before it is created

Following test is always failing (this runs on a linux system, the question is not about other OSes): from time import time from decimal import Decimal from pathlib import Path def test_timing(): start = Decimal(time()) …
zezollo
  • 4,606
  • 5
  • 28
  • 59
1
vote
0 answers

I want to get last modified date in php (stat failed)

what's wrong with my code? this code displays a warning like Warning: filemtime(): stat failed for.. and shows the wrong date as a modified date. $i = 0; while ($i < count($files)) { $current_file = $files[$i]; echo…
Praneeth Madush
  • 158
  • 2
  • 12
1
vote
0 answers

Convert Ansible stat's mtime output to YYMMDD-HHMMSS

I'm trying to extract a file's last modified time in the format YYMMDD-HHMMSS (ex:210422-135018) using Ansible's stat module. I'm getting the file's mtime in a playbook: - name: stat stat: path: /path/to/file register: file …
dkd6
  • 65
  • 1
  • 6
1
vote
1 answer

how do I create tar file keeping directory structure intact and excluding some files based on the last modified date

This is a directory structure: I want to tar Directory1 with the conditions - It should include only those files that are modified in the last three days. Keep the directory structure intact. The final tared output should be -
p zankat
  • 75
  • 2
  • 14
1
vote
0 answers

How can I force browser to refresh the cache with php?

I am a beginner web "developer". I'm making the site of our dog kennel. I've been facing the cache problem for days. I found out PHP filemtime could do the job, I just want to ask, if I put the PHP code like this, would it work? If not, could you…
1
vote
3 answers

How to use PHP glob() with minimum file date (filemtime)?

I want to get a range of files with PHP glob function, but no older than a month (or other specified date range). My current code: $datetime_min = new DateTime('today - 4 weeks'); $product_files =…
Emiel
  • 33
  • 5
1
vote
1 answer

How do I set the mtime of a symlink in TCL?

file mtime can be used to set the modifcation time of a file. But if it's a symlink, it will set the mtime of the target. How do I set the mtime of the symlink itself?
Lars Brinkhoff
  • 13,542
  • 2
  • 28
  • 48
1
vote
1 answer

Detect if a command modifies any files from a directory within a Python script

I have a Python script: import subprocess subprocess.run(['black', 'src']) I would like to tell if the command run by subprocess modified any file in the folder src - so, I'd like my script to look like this: import…
ignoring_gravity
  • 6,677
  • 4
  • 32
  • 65
1
vote
1 answer

How to catch error during mass sort of files that constantly change

array_multisort(array_map('filemtime', ($files = glob("*.json"))), SORT_DESC, $files); This is the most efficient method to sort 45k json files I have found so far. Works great, except in my case the files are constantly being changed by a game…
Chris
  • 11
  • 1
1
vote
1 answer

php filemtime in a loop at CLI on Windows doesn't get updates

I have a loop while (true) { $time = filemtime($file); echo date("Y m d H i s", $time) . PHP_EOL; sleep(3); } Then I change the file, and PHP doesn't see modification unless I restart the loop. After restart, PHP shows new mod date. How…
mevsme
  • 441
  • 5
  • 15
1
vote
1 answer

Print remote servers FILENAME, MTIME in the screen using Net::SFTP::Foreign Perl Module

I am writing a code which need to get the file from remote server using Net::SFTP::Foreign Perl module. Here is the script. my $sftp = Net::SFTP::Foreign->new( host=>$host, user=>$user, …
vkk05
  • 3,137
  • 11
  • 25
1
vote
2 answers

How to obtain modified date/time of file? filemtime/fileatime does not return correct value

On my server running under Windows XP and PHP 5.4.16, it seems like the filemtime and fileatime returns value of creation time. $r = touch("/$fname",10,10); if ($r===false) echo " FAILED "; $stat = stat("/$fname"); print_r($stat); $int =…
Johny Bony
  • 375
  • 2
  • 9
1
vote
2 answers

PHP - filemtime function error

Hi i get this error when a cache script is included in my site.. Warning: filemtime() [function.filemtime]: stat failed for index.php in C:\xampp\htdocs\Content\content\cache.php on line 6 Here is the script:
Ricki
  • 933
  • 2
  • 15
  • 33