php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73426 createFromFormat with 'z' format char results in incorrect time
Submitted: 2016-10-31 07:54 UTC Modified: 2016-10-31 10:31 UTC
From: vaclav dot sir at gmail dot com Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 7.1.0RC5 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: vaclav dot sir at gmail dot com
New email:
PHP Version: OS:

 

 [2016-10-31 07:54 UTC] vaclav dot sir at gmail dot com
Description:
------------
When you use the 'z' format character after the time ('H:i:s z'), the time information gets parsed incorrectly. If you use the 'z' char in front of the time ('z H:i:s'), it parses fine.

Affected versions are 7.1.0RC4 and 7.1.0RC5: https://3v4l.org/QOS7s

Test script:
---------------
<?php

$date = '12:00:00 15';
$format = 'H:i:s z';

var_dump(DateTime::createFromFormat($format, $date));

Expected result:
----------------
object(DateTime)#1 (3) {
  ["date"]=>
  string(26) "2016-01-16 12:00:00.000000"
  ["timezone_type"]=>
  int(3)
  ["timezone"]=>
  string(16) "Europe/Amsterdam"
}

Actual result:
--------------
object(DateTime)#1 (3) {
  ["date"]=>
  string(31) "2016-01-16 11:59:55.-2147483648"
  ["timezone_type"]=>
  int(3)
  ["timezone"]=>
  string(16) "Europe/Amsterdam"
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-10-31 10:31 UTC] derick@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: derick
 [2016-10-31 10:44 UTC] derick@php.net
Automatic comment on behalf of github@derickrethans.nl
Revision: http://git.php.net/?p=php-src.git;a=commit;h=1d1a7feecfab42bb3a0657ed684e11abeae45315
Log: - Fixed bug #73426: createFromFormat with 'z' format char results in incorrect time.
 [2016-10-31 10:44 UTC] derick@php.net
-Status: Assigned +Status: Closed
 [2016-11-09 03:33 UTC] krakjoe@php.net
Automatic comment on behalf of github@derickrethans.nl
Revision: http://git.php.net/?p=php-src.git;a=commit;h=1d1a7feecfab42bb3a0657ed684e11abeae45315
Log: - Fixed bug #73426: createFromFormat with 'z' format char results in incorrect time.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jan 28 23:01:28 2025 UTC