Bug #52378 [NEW]: new DateTime(time()) failed and should not
| From: | odoucet@php.net | Date: | Mon, 19 Jul 2010 14:03:07 +0000 |
| Subject: | Bug #52378 [NEW]: new DateTime(time()) failed and should not | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-152530@lists.php.net to get a copy of this message | ||
From:
Operating system:
PHP version: 5.3.2
Package: Date/time related
Bug Type: Bug
Bug description:new DateTime(time()) failed and should not
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 bug report at http://bugs.php.net/bug.php?id=52378&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52378&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52378&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52378&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=52378&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52378&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=52378&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=52378&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=52378&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=52378&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=52378&r=support
Expected behavior: http://bugs.php.net/fix.php?id=52378&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=52378&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=52378&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=52378&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52378&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52378&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=52378&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=52378&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=52378&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=52378&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=52378&r=mysqlcfg