php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41751 touch() works incorrectly in Windows.
Submitted: 2007-06-20 21:28 UTC Modified: 2007-06-27 11:40 UTC
From: aeolianmeson at blitzeclipse dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.2.3 OS: Windows XP SP2
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: aeolianmeson at blitzeclipse dot com
New email:
PHP Version: OS:

 

 [2007-06-20 21:28 UTC] aeolianmeson at blitzeclipse dot com
Description:
------------
Touch appears to always apply a timestamp that is exactly one-hour earlier then the given timestamp, in Windows. It appears to work fine in PHP 5.0.4 and 4.1.2 in Linux.

Reproduce code:
---------------
touch('b', 0);

var_dump(stat('b'));

Expected result:
----------------
array(26) {
  [0]=>
  int(2)
  [1]=>
  int(0)
  [2]=>
  int(33206)
  [3]=>
  int(1)
  [4]=>
  int(0)
  [5]=>
  int(0)
  [6]=>
  int(2)
  [7]=>
  int(0)
  [8]=>
  int(-3600)
  [9]=>
  int(-3600)
  [10]=>
  int(1182374129)
  [11]=>
  int(-1)
  [12]=>
  int(-1)
  ["dev"]=>
  int(2)
  ["ino"]=>
  int(0)
  ["mode"]=>
  int(33206)
  ["nlink"]=>
  int(1)
  ["uid"]=>
  int(0)
  ["gid"]=>
  int(0)
  ["rdev"]=>
  int(2)
  ["size"]=>
  int(0)
  ["atime"]=>
  int(0)
  ["mtime"]=>
  int(0)
  ["ctime"]=>
  int(1182374129)
  ["blksize"]=>
  int(-1)
  ["blocks"]=>
  int(-1)
}

Actual result:
--------------
// mtime and ctime are -3600.

array(26) {
  [0]=>
  int(2)
  [1]=>
  int(0)
  [2]=>
  int(33206)
  [3]=>
  int(1)
  [4]=>
  int(0)
  [5]=>
  int(0)
  [6]=>
  int(2)
  [7]=>
  int(0)
  [8]=>
  int(-3600)
  [9]=>
  int(-3600)
  [10]=>
  int(1182374129)
  [11]=>
  int(-1)
  [12]=>
  int(-1)
  ["dev"]=>
  int(2)
  ["ino"]=>
  int(0)
  ["mode"]=>
  int(33206)
  ["nlink"]=>
  int(1)
  ["uid"]=>
  int(0)
  ["gid"]=>
  int(0)
  ["rdev"]=>
  int(2)
  ["size"]=>
  int(0)
  ["atime"]=>
  int(-3600)
  ["mtime"]=>
  int(-3600)
  ["ctime"]=>
  int(1182374129)
  ["blksize"]=>
  int(-1)
  ["blocks"]=>
  int(-1)
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-06-20 21:53 UTC] sniper@php.net
What does this output for you:

<?php

echo time(), "\n";
touch('b'); // 2nd parameter is optional..
$b = stat('b');
echo $b['ctime'], "\n";

?>



 [2007-06-20 21:58 UTC] aeolianmeson at blitzeclipse dot com
1182376591
1182376591

ctime doesn't appear to be afflicted.

Dustin Oprea
 [2007-06-20 22:26 UTC] sniper@php.net
Actually I think it's just the thing that you pass '0' to touch() as 2nd parameter..
 [2007-06-20 22:27 UTC] aeolianmeson at blitzeclipse dot com
It's just easier to see when I use (0). I was using normal timestamps before.
 [2007-06-20 22:30 UTC] aeolianmeson at blitzeclipse dot com
Plus, this only happens with Windows.

Dustin
 [2007-06-21 13:30 UTC] sniper@php.net
Of course. What is your system timezone set to? And what about the timezone setting in php.ini, date.timezone ?
 [2007-06-21 13:33 UTC] aeolianmeson at blitzeclipse dot com
Timezone is set to -5 at runtime. OS is setting to Detroit (-5)... But, timezones don't matter until epoch times are converted to strings-- This wouldn't apply since we're just talking about the timestamps.
 [2007-06-21 13:37 UTC] sniper@php.net
Yes, that's how it should work but maybe not. What is date.timezone set for you?

 [2007-06-21 13:38 UTC] aeolianmeson at blitzeclipse dot com
It's set to 'America/Detroit' at runtime, which is still -5 (or -4 during DST).
 [2007-06-24 13:14 UTC] sniper@php.net
See also bug #41786
 [2007-06-27 11:40 UTC] tony2001@php.net
Duplicate of bug #40568.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jun 04 17:01:27 2025 UTC