php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50051 strtotime
Submitted: 2009-11-01 20:29 UTC Modified: 2009-11-02 06:07 UTC
From: tailinchu at gmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.2.11 OS:
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: tailinchu at gmail dot com
New email:
PHP Version: OS:

 

 [2009-11-01 20:29 UTC] tailinchu at gmail dot com
Description:
------------
strtotime() cannot create correct timestamp.

Reproduce code:
---------------
echo date('Ymd',strtotime('200910'));

Expected result:
----------------
20091001

Actual result:
--------------
20091101

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-11-01 20:32 UTC] sjoerd@php.net
Thank you for your bug report.

The string you supply, 200910, is not a complete date. Why do you think this should return 2009-10-01?
 [2009-11-01 20:35 UTC] sjoerd@php.net
Strtotime('200910') creates a correct timestamp on today, with a time of 20:09:10.
 [2009-11-01 20:37 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

"200910" gets parsed as 20:09:10 and not 2009-10:

derick@kossu:~$ php -r 'var_dump(date_parse("200910"));'
array(12) {
  ["year"]=>
  bool(false)
  ["month"]=>
  bool(false)
  ["day"]=>
  bool(false)
  ["hour"]=>
  int(20)
  ["minute"]=>
  int(9)
  ["second"]=>
  int(10)
  ["fraction"]=>
  float(0)
  ["warning_count"]=>
  int(0)
  ["warnings"]=>
  array(0) {
  }
  ["error_count"]=>
  int(0)
  ["errors"]=>
  array(0) {
  }
  ["is_localtime"]=>
  bool(false)
}

 [2009-11-02 06:07 UTC] tailinchu at gmail dot com
Thanks.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Sep 28 01:01:27 2024 UTC