3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $dt = new DateTime('now', new \DateTimeZone('UTC')); for($i = 0; $i < 1000; $i++) { $dt->modify("+3 days"); $dt = clone $dt; $dt->modify("-6 weeks"); $serial = serialize(array($dt)); if (strlen($serial) < 100) { var_dump( $dt ); var_dump( $serial ); break; } } var_dump( $serial );
based on Aj1gg
Output for 7.2.0
string(124) "a:1:{i:0;O:8:"DateTime":3:{s:4:"date";s:26:"1909-01-30 09:12:56.002718";s:13:"timezone_type";i:3;s:8:"timezone";s:3:"UTC";}}"
Output for 7.1.10
string(124) "a:1:{i:0;O:8:"DateTime":3:{s:4:"date";s:26:"1909-01-30 09:12:56.003711";s:13:"timezone_type";i:3;s:8:"timezone";s:3:"UTC";}}"
Output for 7.1.7
string(124) "a:1:{i:0;O:8:"DateTime":3:{s:4:"date";s:26:"1909-01-30 09:12:56.002645";s:13:"timezone_type";i:3;s:8:"timezone";s:3:"UTC";}}"
Output for 7.1.6
string(124) "a:1:{i:0;O:8:"DateTime":3:{s:4:"date";s:26:"1909-01-30 09:12:56.010682";s:13:"timezone_type";i:3;s:8:"timezone";s:3:"UTC";}}"
Output for 7.1.5
string(124) "a:1:{i:0;O:8:"DateTime":3:{s:4:"date";s:26:"1909-01-30 09:12:56.011665";s:13:"timezone_type";i:3;s:8:"timezone";s:3:"UTC";}}"
Output for 7.1.0
string(124) "a:1:{i:0;O:8:"DateTime":3:{s:4:"date";s:26:"1909-01-30 09:12:56.004095";s:13:"timezone_type";i:3;s:8:"timezone";s:3:"UTC";}}"
Output for 5.4.30 - 5.4.45, 5.5.14 - 7.0.20
string(124) "a:1:{i:0;O:8:"DateTime":3:{s:4:"date";s:26:"1909-01-30 09:12:56.000000";s:13:"timezone_type";i:3;s:8:"timezone";s:3:"UTC";}}"
Output for 5.3.0 - 5.4.29, 5.5.0 - 5.5.13
string(117) "a:1:{i:0;O:8:"DateTime":3:{s:4:"date";s:19:"1909-01-30 09:12:56";s:13:"timezone_type";i:3;s:8:"timezone";s:3:"UTC";}}"
Output for 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/2gTmZ on line 3 object(DateTime)#2 (0) { } string(29) "a:1:{i:0;O:8:"DateTime":0:{}}" string(29) "a:1:{i:0;O:8:"DateTime":0:{}}"
Output for 5.0.0 - 5.1.6
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/2gTmZ on line 3 Fatal error: Class 'DateTime' not found in /in/2gTmZ on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/2gTmZ on line 3 Parse error: syntax error, unexpected T_VARIABLE in /in/2gTmZ on line 9
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/2gTmZ on line 3 Parse error: parse error, unexpected T_VARIABLE in /in/2gTmZ on line 9
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/2gTmZ on line 3 Parse error: parse error in /in/2gTmZ on line 9
Process exited with code 255.