php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27061 using each, getdate and while will output wrong data
Submitted: 2004-01-27 12:55 UTC Modified: 2004-01-27 13:02 UTC
From: PAUL_MYERS at YAHOO dot COM Assigned:
Status: Not a bug Package: Output Control
PHP Version: 4.3.4 OS: windows and GNULinux
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: PAUL_MYERS at YAHOO dot COM
New email:
PHP Version: OS:

 

 [2004-01-27 12:55 UTC] PAUL_MYERS at YAHOO dot COM
Description:
------------
running the code below will ouput the weekday value and the Unix datecode! - obviously I have shortened my code so this is non relevant as there is another way but I'm not sure this should happen (it would be interesting to know why?)
this can be resolved by changing 
if ($element[key] == "weekday" )

to 

if ($element[key] == "weekday" && $element[key] != "0")

Reproduce code:
---------------
<html>
<body>
<?	
$timestamp = date ("U");
	$day1a = getdate ($timestamp);
	while ( $element = each ($day1a)) {
	  if ($element[key] == "weekday" )  {
	    $day = $element[value];
	    echo " Day ";
	    echo $day;
	    echo "<br><br>";
	  }
        }
?>
</body>
</html>

Expected result:
----------------
Day Tuesday


Actual result:
--------------
Day Tuesday

Day 1075224592



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-27 13:02 UTC] sniper@php.net
Use '===' and '!==' there. This is not bug..

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 13:01:28 2024 UTC