|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75182 Should DateTimeImmutable/DateTime throw a exception
Submitted: 2017-09-11 09:28 UTC Modified: -
From: nyamsprod at gmail dot com Assigned:
Status: Open Package: Date/time related
PHP Version: Irrelevant OS:
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.
Block user comment
Status: Assign to:
Bug Type:
From: nyamsprod at gmail dot com
New email:
PHP Version: OS:


 [2017-09-11 09:28 UTC] nyamsprod at gmail dot com
in PHP7.1+ DateInterval can take the number of microseconds, as a fraction of a second with the DateInterval::f public property.

If DateInterval::f is set with a value greater than 1, DateInterval accepts it without warning. If we modify a DateTimeInterface object with this "invalid" DateInterval, a invalid DateTimeInterface object is returned.


Test script:
$interval = new DateInterval('PT1S');
$interval->f = 500000;  // excepted an Exception
// expected an OverflowException or a valid DateTimeInterface 

returns an Invalid DateTimeInterface

object(DateTimeImmutable)#3 (3) {
 ["date"]=> string(31) "2017-03-15 00:00:03.-2147483648"
 ["timezone_type"]=> int(3)
 ["timezone"]=> string(16) "Europe/Amsterdam"


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Jul 29 03:01:28 2021 UTC