php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #51538 strptime() buggy prior PHP 5.2.0
Submitted: 2010-04-12 11:10 UTC Modified: 2010-10-20 02:33 UTC
From: alex dot schuch at gmx dot de Assigned: kalle (profile)
Status: Closed Package: Documentation problem
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: alex dot schuch at gmx dot de
New email:
PHP Version: OS:

 

 [2010-04-12 11:10 UTC] alex dot schuch at gmx dot de
Description:
------------
A note should be added to strptime() documentation, as the function is not
working according to the documentation before PHP 5.2.0.

http://bugs.php.net/38524
http://php.net/ChangeLog-5.php

Maybe something like:
Prior PHP 5.2.0, strptime() returns random values for parts not included in the
format string (see bug #38524).


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-10 19:13 UTC] philip@php.net
Surely it's not "random", so is there some logic behind these incorrect [and 
seemingly random] values prior to 5.2.0? Or maybe we could use the word 
'undefined' instead. Thoughts?

The changelog entry is "strptime() does not initialize the internal date storage 
structure" although I'm unsure exactly what that means.
 [2010-08-12 14:54 UTC] alex dot schuch at gmx dot de
I just had a look at the PHP source:

svn diff -c218534 ext/standard/datetime.c

The fix to this problem was the initialisation of the struct with zero (using memset()).

From the manual "man 3 strptime":

In principle, this function does not initialize tm but only stores the values specified. This means that tm should be initialized before the call. Details differ a bit between different Unix systems. The glibc implementation does not touch those fields which are not explicitly specified, except that it recomputes the tm_wday and tm_yday field if any of the year, month, or day elements changed.

So in easy words:
The elements of the struct are not initialised. strptime() only sets the values according to the pattern so that non-given values were not overwritten - they stayed at their uninitialised value.
 [2010-10-20 02:33 UTC] kalle@php.net
Automatic comment from SVN on behalf of kalle
Revision: http://svn.php.net/viewvc/?view=revision&revision=304520
Log: Fixed bug #51538 (strptime() buggy prior PHP 5.2.0)
 [2010-10-20 02:33 UTC] kalle@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: kalle
 [2010-10-20 02:33 UTC] kalle@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [2020-02-07 06:09 UTC] phpdocbot@php.net
Automatic comment on behalf of kalle
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=138a9e241450b2fbebf330bf6bc32e83fe091275
Log: Fixed bug #51538 (strptime() buggy prior PHP 5.2.0)
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 05:00:01 2026 UTC