|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48454 touch() does not modify accessed time in Windows
Submitted: 2009-06-02 15:52 UTC Modified: 2009-08-18 14:47 UTC
From: soapergem at gmail dot com Assigned: pajoye (profile)
Status: Closed Package: Filesystem function related
PHP Version: 5.2.9 OS: win32 only - Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: soapergem at gmail dot com
New email:
PHP Version: OS:


 [2009-06-02 15:52 UTC] soapergem at gmail dot com
The touch() command does not actually modify the accessed time of a file on a Windows platform. After calling touch() on a file with an access time specified, the access time is set to the current time.

Reproduce code:

$file = 'C:\\test.txt';
$mtime = filemtime($file);
$atime = fileatime($file);

$newtime = mktime(0, 0, 0, 1, 1, 2009);
$result1 = touch($file, $mtime, $newtime);
$result2 = ( $atime != fileatime($file) );



Expected result:
On the first run, we should expect the file C:\test.txt to have an access time of January 1st, 2009, and this expected PHP output:


Actual result:
Instead, the file C:\test.txt will have an access time of whenever the script ran, and this is the PHP output we get:



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-02 20:05 UTC]
Works fine with *nix, fails with Windows.
 [2009-06-04 05:49 UTC]
Reproduced in both 5.2.9, 5.2.10rc2-dev and 5.3.0rc3-dev on Vista
 [2009-08-18 14:47 UTC]
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

Fixed in 5.3+
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Feb 01 20:04:13 2023 UTC