php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #76785 DateTime construction with a negative year argument shows different behaviours
Submitted: 2018-08-23 15:29 UTC Modified: 2022-06-05 14:25 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: thijs at tsjeng dot nl Assigned: derick (profile)
Status: Wont fix Package: Date/time related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: thijs at tsjeng dot nl
New email:
PHP Version: OS:

 

 [2018-08-23 15:29 UTC] thijs at tsjeng dot nl
Description:
------------
DateTime object instantiation with negative input string via 
'createFromFormat' and same argument just as construction argument display weird behaviour. 

Test script:
---------------
var_dump(DateTime::createFromFormat('Y-m-d', '0045-01-01')); // works
var_dump(DateTime::createFromFormat('Y-m-d', '-0045-01-01')); //  false
var_dump(DateTime::createFromFormat('-Y-m-d', '-0045-01-01')); // works, but year is positive instead of negative

var_dump(new DateTime('0045-01-01')); // works
var_dump(new DateTime('-0045-01-01')); // works
var_dump(new DateTime('0045/01/01')); // works

var_dump(new DateTime('-0045/01/01')); // exception



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-08-23 17:10 UTC] requinix@php.net
Fortunately 'U' already supports signed numbers so extending that to 'Y' shouldn't be difficult.
 [2018-11-28 14:19 UTC] bjoern dot fischer at dezem dot de
We are affected by this issue too.

It can be easily reproduced here:
https://3v4l.org/LY6FJ
 [2020-01-20 17:35 UTC] girgias@php.net
-Assigned To: +Assigned To: derick
 [2020-01-20 17:35 UTC] girgias@php.net
This maybe should be reclassified as a Feature request, leaving Derick to decide about it.
 [2021-04-06 18:40 UTC] derick@php.net
-Type: Bug +Type: Feature/Change Request
 [2022-06-05 14:25 UTC] derick@php.net
-Status: Assigned +Status: Wont fix
 [2022-06-05 14:25 UTC] derick@php.net
I am marking this as "won't fix". If you are still interested in having this feature, please file a new issue at https://github.com/php/php-src/issues/ with a well defined and explained use case.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC