php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63222 DateTime::createFromFormat() wrong with reset and D,l
Submitted: 2012-10-05 12:28 UTC Modified: -
From: gron1987 at gmail dot com Assigned:
Status: Open Package: Date/time related
PHP Version: 5.4.7 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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gron1987 at gmail dot com
New email:
PHP Version: OS:

 

 [2012-10-05 12:28 UTC] gron1987 at gmail dot com
Description:
------------
We found that createFromFormat work incorrect.
If we use reset in format ("!") and don't send year then we will receive new date 
in 1970 year, php don't change day of week ("Wed"), it change day("05").

It work correct in 5.3.8

Maybe you broke this when fix this:
https://bugs.php.net/bug.php?id=54851

Test script:
---------------
<?php
$str = "6:15 pm Wed, Oct 5";
$date = DateTime::createFromFormat("!g:i a D, M d", $str);
var_dump($date);

Expected result:
----------------
class DateTime#1 (3) {
  public $date =>
  string(19) "1970-10-05 18:15:00"
  public $timezone_type =>
  int(3)
  public $timezone =>
  string(13) "Europe/Berlin"
}

(php 5.3.8)

Actual result:
--------------
object(DateTime)#1 (3) {
  ["date"]=>
  string(19) "1970-10-07 18:15:00"
  ["timezone_type"]=>
  int(3)
  ["timezone"]=>
  string(15) "Europe/Helsinki"
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Aug 07 15:01:25 2020 UTC