Doc #54000 [Opn->Bgs]: date_create bug

From: Date: Tue, 15 Feb 2011 21:31:43 +0000
Subject: Doc #54000 [Opn->Bgs]: date_create bug
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-5999@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=54000&edit=1 ID: 54000 Updated by: derick@php.net Reported by: phunsanit at hotmail dot com Summary: date_create bug -Status: Open +Status: Bogus Type: Documentation Problem Package: Windows Installer Operating System: windows 7 / linux PHP Version: 5.3.5 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php This is correct. PHP automatically adjust for value underflows and overflows. Since more recent PHP versions, it will add a warning for invalid dates though: <?php $date = date_create('2011-02-31'); var_dump(date_get_last_errors()); ?> array(4) { ["warning_count"]=> int(1) ["warnings"]=> array(1) { [11]=> string(27) "The parsed date was invalid" } ["error_count"]=> int(0) ["errors"]=> array(0) { } } Previous Comments: ------------------------------------------------------------------------ [2011-02-12 15:46:53] phunsanit at hotmail dot com Description: ------------ --- From manual page: http://www.php.net/datetime.construct#Errors/Exceptions --- i create date 2011-02-31 it impossible but menthod date_create don't error it return 2011-02-31 Test script: --------------- $date = date_create('2011-02-31'); if (!$date) { $e = date_get_last_errors(); foreach ($e['errors'] as $error) { echo "$error\n"; } } else { echo date_format($date, 'Y-m-d'); } return 2011-03-03 Expected result: ---------------- 2011-03-03 Actual result: -------------- return false ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=54000&edit=1

« previous php.doc.bugs (#5999) next »