xref: /PHP-7.1/ext/date/tests/bug67308.phpt (revision fdb2709d)
1--TEST--
2Bug #67308 (Serialize of DateTime truncates fractions of second)
3--INI--
4date.timezone=America/Vancouver
5--FILE--
6<?php
7// Ensure we can still unserialize the old style.
8var_dump(unserialize('O:8:"DateTime":3:{s:4:"date";s:19:"2005-07-14 22:30:41";s:13:"timezone_type";i:3;s:8:"timezone";s:13:"Europe/London";}'));
9
10// New style.
11var_dump(unserialize('O:8:"DateTime":3:{s:4:"date";s:26:"2005-07-14 22:30:41.123456";s:13:"timezone_type";i:3;s:8:"timezone";s:13:"Europe/London";}'));
12--EXPECTF--
13object(DateTime)#%d (3) {
14  ["date"]=>
15  string(26) "2005-07-14 22:30:41.000000"
16  ["timezone_type"]=>
17  int(3)
18  ["timezone"]=>
19  string(13) "Europe/London"
20}
21object(DateTime)#%d (3) {
22  ["date"]=>
23  string(26) "2005-07-14 22:30:41.123456"
24  ["timezone_type"]=>
25  int(3)
26  ["timezone"]=>
27  string(13) "Europe/London"
28}
29