Bug #73294 [Opn]: DateTime wrong when date string is negative

From: Date: Sun, 12 Feb 2017 17:55:03 +0000
Subject: Bug #73294 [Opn]: DateTime wrong when date string is negative
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207285@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73294&edit=1 ID: 73294 Updated by: derick@php.net Reported by: andrmoel at googlemail dot com Summary: DateTime wrong when date string is negative Status: Open Type: Bug Package: Date/time related Operating System: Ubuntu PHP Version: 7.0.11 Block user comment: N Private report: N New Comment: I have a fix and test case for this, which I'll merge when I make a new timelib release (shortly). Previous Comments: ------------------------------------------------------------------------ [2016-10-11 16:42:05] andrmoel at googlemail dot com Description: ------------ When you run the test script, the second outpot is parsed false. It returns the date minus one day. Maybe this error occures with other strings also. Test script: --------------- <?php $dt = new DateTime('-1999-06-22 00:00:00'); echo "\nThis should be -1999-06-22 00:00:00 -> " . $dt->format('Y-m-d H:i:s'); $dt = new DateTime('-1916-06-22 00:00:00'); echo "\nThis should be -1916-06-22 00:00:00 -> " . $dt->format('Y-m-d H:i:s'); Expected result: ---------------- This should be -1999-06-22 00:00:00 -> -1999-06-22 00:00:00 This should be -1916-06-22 00:00:00 -> -1916-06-22 00:00:00 Actual result: -------------- This should be -1999-06-22 00:00:00 -> -1999-06-22 00:00:00 This should be -1916-06-22 00:00:00 -> -1916-06-21 00:00:00 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=73294&edit=1

« previous php.bugs (#207285) next »