|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38524 strptime returns random values for unparsed parts
Submitted: 2006-08-20 16:54 UTC Modified: 2006-08-20 18:27 UTC
From: php at felixdd dot de Assigned:
Status: Closed Package: Date/time related
PHP Version: 5.1.5 OS: Linux
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.
Block user comment
Status: Assign to:
Bug Type:
From: php at felixdd dot de
New email:
PHP Version: OS:


 [2006-08-20 16:54 UTC] php at felixdd dot de
strptime returns random values for parts not included in the format string.

manpage of strptime says:
"In principle, this function does not initialize tm but  only stores the values specified. This means that tm should be initialized before the call."

But this isn't done in ext/standard/datetime.c
neither in 5.1.5 nor in 5.2.0RC2

Reproduce code:
// only date, no time given
print_r(strptime('2006-08-20', '%Y-%m-%d'));

Expected result:
    [tm_sec] => 0
    [tm_min] => 0
    [tm_hour] => 0
    [tm_mday] => 20
    [tm_mon] => 7
    [tm_year] => 106
    [tm_wday] => 0
    [tm_yday] => 231
    [unparsed] => 

Actual result:
    [tm_sec] => 140252532  <-- random values each time called
    [tm_min] => 13 <-- random values each time called
    [tm_hour] => 1 <-- random values each time called
    [tm_mday] => 20
    [tm_mon] => 7
    [tm_year] => 106
    [tm_wday] => 0
    [tm_yday] => 231
    [unparsed] => 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-20 18:27 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Sep 22 13:01:24 2023 UTC