|  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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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