php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php at felixdd dot de
New email:
PHP Version: OS:

 

 [2006-08-20 16:54 UTC] php at felixdd dot de
Description:
------------
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:
----------------
Array
(
    [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:
--------------
Array
(
    [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] => 
)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-20 18:27 UTC] iliaa@php.net
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
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 13:01:29 2024 UTC