Doc #52378 [Opn]: new DateTime(time()) failed and should not

From: Date: Mon, 19 Jul 2010 21:10:43 +0000
Subject: Doc #52378 [Opn]: new DateTime(time()) failed and should not
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-4712@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: dtajchreber@php.net Reported by: odoucet@php.net Summary: new DateTime(time()) failed and should not Status: Open Type: Documentation Problem Package: Date/time related PHP Version: 5.3.2 -Assigned To: +Assigned To: dtajchreber New Comment: <?php var_dump(new DateTime('@' . time())); Previous Comments: ------------------------------------------------------------------------ [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 (#4712) next »