php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #54117 Parameter 'z' false
Submitted: 2011-02-28 11:10 UTC Modified: 2011-11-21 02:59 UTC
From: a dot borngesser at berlin dot de Assigned: danielc (profile)
Status: Wont fix Package: Date/time related
PHP Version: Irrelevant OS: Irrelevant
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: a dot borngesser at berlin dot de
New email:
PHP Version: OS:

 

 [2011-02-28 11:10 UTC] a dot borngesser at berlin dot de
Description:
------------
---
From manual page: http://www.php.net/function.date#Parameter-Liste
---
Parameter ist im Grundaufbau falsch.
"z 	Der Tag des Jahres (von 0 beginnend) 	0 bis365"
                            ===============     = 

Der erste Tag des Jahres ist nicht '0' sondern '1'!
Natürlich ist es normal, das von 0 die Zählung beginnt, aber man sollte evtl. bei einem Parameter dies intern gleich um +1 hochzählen und nicht den Programmierern überlassen.
Ich habe jetzt schon mehrere Fälle gehabt, wo der Parameter direkt genutzt wurde, was dann zu falschen Ergebnissen geführt hat.
Wenn ein Parameter den hochgezählten Tag des Jahres angeben soll, sollte dies auch so sein und nicht 'der hochgezählte Tag des Jahres -1'.


Test script:
---------------
echo "Der 1.1. 2010 hatte die LOS#:  ".date ("z",mktime(0,0,0,1,1,2010));





Expected result:
----------------
Der 1.1. 2010 hatte die LOS#: 1

Actual result:
--------------
Der 1.1. 2010 hatte die LOS#: 0

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-28 11:11 UTC] pajoye@php.net
-Status: Open +Status: Feedback
 [2011-02-28 11:11 UTC] pajoye@php.net
Please report your bug in English.
 [2011-02-28 11:29 UTC] a dot borngesser at berlin dot de
-Status: Feedback +Status: Open
 [2011-02-28 11:29 UTC] a dot borngesser at berlin dot de
Sorry, my text now in english.
The parameter 'z' is false from its basic set-up.
The first day of the year is '1' not '0'.
I know, that the count starts with 0, but it would be better to change the code of the parameter, than to leave it to the programmers.
(I had some cases where it was used simply as is. The results where simply false, and when using it in a very basic way by just displaying it, you don't think of a mistake.)
If a parameter is for returning the "incremented day of the year", it should do exactly this, and not the "incremented day of the year -1".
 [2011-03-16 09:42 UTC] a dot borngesser at berlin dot de
Is someone working on this issue or shut I open a new thread (and of course in english this time)?
 [2011-11-21 02:59 UTC] danielc@php.net
It is impossible to change the behavior of an existing format parameter due to the current behavior being relied on by existing users.  If you like, you may open a feature request for a new format parameter, but this does not seem like an important feature since using z + 1 is a simple workaround.
 [2011-11-21 02:59 UTC] danielc@php.net
-Status: Open +Status: Wont fix -Assigned To: +Assigned To: danielc
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 10 05:01:27 2024 UTC