Bug #75249 [Opn->Nab]: datetime constructor does not throws exception on invalida date

From: Date: Sat, 23 Sep 2017 14:41:25 +0000
Subject: Bug #75249 [Opn->Nab]: datetime constructor does not throws exception on invalida date
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-211331@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75249&edit=1 ID: 75249 Updated by: requinix@php.net Reported by: contatto at developiu dot it Summary: datetime constructor does not throws exception on invalida date -Status: Open +Status: Not a bug Type: Bug Package: Date/time related Operating System: linux PHP Version: 7.1.9 Block user comment: N Private report: N New Comment: If the *format* is invalid. Your example uses the perfectly acceptable YYYY-MM-DD format - the DD value being too high for the given month is something else. If you want to know whether the date itself was invalid then you can use getLastErrors(): https://3v4l.org/SIEmX Previous Comments: ------------------------------------------------------------------------ [2017-09-23 14:20:53] contatto at developiu dot it Description: ------------ In the ducumentation it is stated that from php 5.3 if time contains an invalid date/time format, then an exception is now thrown. Previously an error was emitted. This does not happen always, as the code below shows. No exception is thrown and the date object is the first of march. Note: I'm using php from remi repositories and php --version shows version 7.1.7 which is not an available options in the select before. Test script: --------------- $d=new DateTime("2017-02-29"); var_dump($d); ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75249&edit=1

« previous php.bugs (#211331) next »