php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72354 var_export print extra precision for datetime variable
Submitted: 2016-06-07 10:43 UTC Modified: 2016-06-07 10:53 UTC
From: sajidm at gmx dot net Assigned: cmb (profile)
Status: Not a bug Package: Date/time related
PHP Version: 5.6.22 OS: linux but may be all
Private report: No CVE-ID: None
 [2016-06-07 10:43 UTC] sajidm at gmx dot net
Description:
------------
if you print datetime variable with var_export function it will print extra precision digits with zeros. This behaviour is since version 5.6.x.





Test script:
---------------
php -r '$d=new DateTime("2016-06-07 12:37:40");var_export($d);echo "\n";'


Expected result:
----------------
DateTime::__set_state(array(
   'date' => '2016-06-07 12:37:40',
   'timezone_type' => 3,
   'timezone' => 'Europe/Berlin',
))

Actual result:
--------------
DateTime::__set_state(array(
   'date' => '2016-06-07 12:37:40.000000',
   'timezone_type' => 3,
   'timezone' => 'Europe/Berlin',
))

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-07 10:53 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Package: *General Issues +Package: Date/time related -Assigned To: +Assigned To: cmb
 [2016-06-07 10:53 UTC] cmb@php.net
> This behaviour is since version 5.6.x.

Actually, it is so as of PHP 5.5.14, due to fixing bug #67308. It
seems very reasonable to me that var_export() also exports the
*exact* time, so this is not a bug, in my opinion.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Jul 21 00:01:26 2019 UTC