Doc #52378 [Bgs->Asn]: new DateTime(time()) failed and should not

From: Date: Tue, 20 Jul 2010 02:44:02 +0000
Subject: Doc #52378 [Bgs->Asn]: new DateTime(time()) failed and should not
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-4714@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=52378&edit=1 ID: 52378 Updated by: aharvey@php.net Reported by: odoucet@php.net Summary: new DateTime(time()) failed and should not -Status: Bogus +Status: Assigned Type: Documentation Problem Package: Date/time related PHP Version: 5.3.2 -Assigned To: dtajchreber +Assigned To: aharvey New Comment: The DateTime::setTimestamp() documentation does advertise passing a timestamp directly to new DateTime(), though, which is unfortunate. I'll tidy it up. Previous Comments: ------------------------------------------------------------------------ [2010-07-19 23:13:31] dtajchreber@php.net After looking through, it seems it's documented here: http://www.php.net/manual/en/datetime.formats.compound.php ------------------------------------------------------------------------ [2010-07-19 23:10:43] dtajchreber@php.net <?php var_dump(new DateTime('@' . time())); ------------------------------------------------------------------------ [2010-07-19 16:03:07] odoucet@php.net Description: ------------ Creating a new DateTime object with a unix timestamp failed with error Uncaught exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string (1279547855) at position 8 (5): Unexpected character' If this is expected behaviour, this should be written in documentation and DateTime::setTimestamp() should be fixed: http://www.php.net/manual/en/datetime.settimestamp.php#Notes "Passing a Unix timestamp to DateTime::__construct() is an alternative when using PHP 5.2." Test script: --------------- <?php var_dump(new DateTime(time())); Expected result: ---------------- no fatal error :) Actual result: -------------- Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string (1279547855) at position 8 (5): Unexpected character' ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52378&edit=1

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