xref: /PHP-8.2/ext/date/tests/bug67308.phpt (revision 7aacc705)
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?>
13--EXPECTF--
14object(DateTime)#%d (3) {
15  ["date"]=>
16  string(26) "2005-07-14 22:30:41.000000"
17  ["timezone_type"]=>
18  int(3)
19  ["timezone"]=>
20  string(13) "Europe/London"
21}
22object(DateTime)#%d (3) {
23  ["date"]=>
24  string(26) "2005-07-14 22:30:41.123456"
25  ["timezone_type"]=>
26  int(3)
27  ["timezone"]=>
28  string(13) "Europe/London"
29}
30