php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47177 touch(<file>, <time - bug here>)
Submitted: 2009-01-21 08:53 UTC Modified: 2009-01-21 19:25 UTC
From: dmitrysp at yandex dot ru Assigned:
Status: Not a bug Package: *Directory/Filesystem functions
PHP Version: 5.2.8 OS: WinXP, W2k
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dmitrysp at yandex dot ru
New email:
PHP Version: OS:

 

 [2009-01-21 08:53 UTC] dmitrysp at yandex dot ru
Description:
------------
Incorrect second argument in touch() on winter/summer time

Reproduce code:
---------------
go1.php
<?
  	echo "Current winter-time (Moscow +3 GTM): ".date("r (T)")." ".phpversion()."\r\n";

	touch("1.txt", mktime(3,0,0,6,1,2008));
    clearstatcache();
  	$t1=filemtime("1.txt");
  	echo "file1: ".date("d/m/Y H:i:s",$t1)." (must be 3:00)\r\n";

	touch("2.txt", mktime(12,0,0,1,2,2009));
    clearstatcache();
  	$t2=filemtime("2.txt");
  	echo "file2: ".date("d/m/Y H:i:s",$t2)." (must be 12:00)\r\n";
?>



go2.php
<?
  	echo "Current winter-time (Moscow +3 GTM): ".date("r (T)")." ".phpversion()."\r\n";
	touch("1.txt", mktime(mt_rand(0,23),mt_rand(0,59),0,6,1,2008,mt_rand(0,1)));
    copy("1.txt", "2.txt");
    clearstatcache();
  	$t1=filemtime("1.txt");
	touch("2.txt", $t1);
    clearstatcache();
  	$t2=filemtime("2.txt");
  	echo "file1: ".date("d/m/Y H:i:s",$t1)."\r\n";
  	echo "file2: ".date("d/m/Y H:i:s",$t2)." (file1 must be equal file2)\r\n";
?>

Expected result:
----------------
========== (1) Windows XP, PHP 5.1.6, go1.php
Current winter-time (Moscow +3 GTM): Wed, 21 Jan 2009 11:01:13 +0300 (MSK) 5.1.6
file1: 01/06/2008 03:00:00 (must be 3:00)
file2: 02/01/2009 12:00:00 (must be 12:00)

========== (2) Windows XP, PHP 5.2.8, go1.php
Current winter-time (Moscow +3 GTM): Wed, 21 Jan 2009 11:01:26 +0300 (MSK) 5.2.8
file1: 01/06/2008 04:00:00 (must be 3:00)
file2: 02/01/2009 12:00:00 (must be 12:00)

========== (3) Windows 2000, PHP 5.2.8, go1.php
Current winter-time (Moscow +3 GTM): Wed, 21 Jan 2009 11:04:59 +0300 (MSK) 5.2.8
file1: 01/06/2008 04:00:00 (must be 3:00)
file2: 02/01/2009 12:00:00 (must be 12:00)

========== (4) Windows 2000, PHP 5.2.6, go1.php
Current winter-time (Moscow +3 GTM): Wed, 21 Jan 2009 11:07:14 +0300 (MSK) 5.2.6
file1: 01/06/2008 04:00:00 (must be 3:00)
file2: 02/01/2009 12:00:00 (must be 12:00)

========== (5) Windows XP, PHP 5.2.6, go1.php
Current winter-time (Moscow +3 GTM): Wed, 21 Jan 2009 11:11:04 +0300 (MSK) 5.2.6
file1: 01/06/2008 04:00:00 (must be 3:00)
file2: 02/01/2009 12:00:00 (must be 12:00)

========== (6) Windows XP, PHP 4.4.2, go1.php
Current winter-time (Moscow +3 GTM): Wed, 21 Jan 2009 11:12:53 +0300 (?????????? ????? (????)) 4.4.2
file1: 01/06/2008 03:00:00 (must be 3:00)
file2: 02/01/2009 12:00:00 (must be 12:00)

========== (7) Windows XP, PHP 3.0.17, go1.php
Current winter-time (Moscow +3 GTM): r (&#9568;????????? ????? (????)) 3.0.17
file1: 01/06/2008 03:00:00 (must be 3:00)
file2: 02/01/2009 12:00:00 (must be 12:00)

---------------------------------------------------

Command `dir 1.txt`:
01.06.2008  03:00                 0 1.txt

---------------------------------------------------
Windows XP, PHP 5.1.6, go2.php

Current winter-time (Moscow +3 GTM): Wed, 21 Jan 2009 11:23:15 +0300 (MSK) 5.2.8
file1: 01/06/2008 18:26:00
file2: 01/06/2008 19:26:00 (file1 must be equal file2)



Actual result:
--------------
go1.php
file1: 01/06/2008 03:00:00 (must be 3:00)

go2.php
filemtime(1.txt) must be equal filemtime(2.txt), after copy(1.txt, 2.txt). 

Shell command "copy 1.txt 2.txt" is correct. And in PHP 4.x/3.x all ok. I need downgrade? .-)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-21 19:25 UTC] jani@php.net
Set the proper timezone in your php.ini. There is no bug here.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC