php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: soapergem at gmail dot com
New email:
PHP Version: OS:

 

 [2009-06-02 15:52 UTC] soapergem at gmail dot com
Description:
------------
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:
---------------
<?php

$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) );

var_dump($result1);
var_dump($result2);

?>

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:

bool(true)
bool(true)


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:

bool(true)
bool(false)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-02 20:05 UTC] jani@php.net
Works fine with *nix, fails with Windows.
 [2009-06-04 05:49 UTC] kalle@php.net
Reproduced in both 5.2.9, 5.2.10rc2-dev and 5.3.0rc3-dev on Vista
 [2009-08-18 14:47 UTC] pajoye@php.net
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
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Fixed in 5.3+
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 19:01:28 2024 UTC