php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42719 incorrect parsing in strptime()
Submitted: 2007-09-20 18:08 UTC Modified: 2007-10-02 11:50 UTC
From: sumorai at gmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.2.4 OS: Mac OS X 10.4.10
Private report: No CVE-ID: None
 [2007-09-20 18:08 UTC] sumorai at gmail dot com
Description:
------------
strptime() seems to have two problems. First is that it returns the 
month - 1 instead of the correct numerical month value. Second is that 
it returns "107" for the year instead of "2007" as it should. I tested 
this in the latest CVS snapshot also (php5.2-200709201630). Also, for 
years prior to 2000, it returns the two-digit year, e.g. 96 instead of 
1996 when using the %Y format code, which is supposed to return the 
four-digit year.

Reproduce code:
---------------
<?
$tmp = strptime("20/Sep/2007:11:51:15","%d/%b/%Y:%H:%M:%S");
var_dump($tmp);
?>

Expected result:
----------------
array(9) {
  ["tm_sec"]=>
  int(15)
  ["tm_min"]=>
  int(51)
  ["tm_hour"]=>
  int(11)
  ["tm_mday"]=>
  int(20)
  ["tm_mon"]=>
  int(9)
  ["tm_year"]=>
  int(2007)
  ["tm_wday"]=>
  int(0)
  ["tm_yday"]=>
  int(0)
  ["unparsed"]=>
  string(0) ""
}

Actual result:
--------------
array(9) {
  ["tm_sec"]=>
  int(15)
  ["tm_min"]=>
  int(51)
  ["tm_hour"]=>
  int(11)
  ["tm_mday"]=>
  int(20)
  ["tm_mon"]=>
  int(8)
  ["tm_year"]=>
  int(107)
  ["tm_wday"]=>
  int(0)
  ["tm_yday"]=>
  int(0)
  ["unparsed"]=>
  string(0) ""
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-02 11:50 UTC] tony2001@php.net
PHP strptime() is just a wrapper for libc's strptime() function -> there is nothing we can do about it.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 02 15:01:29 2025 UTC