3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class SerialDateTime extends DateTime implements JsonSerializable{ public function jsonSerialize(){ return $this->getTimestamp(); } } class StringDateTime extends DateTime{ public function __toString(){ return ''.$this->getTimestamp(); } } $j = new SerialDateTime; $s = new StringDateTime; //echo $j."\n"; echo $s."\n"; echo json_encode(array($j, $s));
Output for 7.3.0rc4
1378912524 [1378912524,{"date":"2013-09-11 17:15:24.002306","timezone_type":3,"timezone":"Europe\/Amsterdam"}]
Output for 7.3.0rc3
1378912524 [1378912524,{"date":"2013-09-11 17:15:24.003779","timezone_type":3,"timezone":"Europe\/Amsterdam"}]
Output for 7.3.0beta1
1378912524 [1378912524,{"date":"2013-09-11 17:15:24.003479","timezone_type":3,"timezone":"Europe\/Amsterdam"}]
Output for 7.3.0alpha1
1378912524 [1378912524,{"date":"2013-09-11 17:15:24.003260","timezone_type":3,"timezone":"Europe\/Amsterdam"}]
Output for 7.2.6
1378912524 [1378912524,{"date":"2013-09-11 17:15:24.003986","timezone_type":3,"timezone":"Europe\/Amsterdam"}]
Output for 7.2.0
1378912524 [1378912524,{"date":"2013-09-11 17:15:24.004186","timezone_type":3,"timezone":"Europe\/Amsterdam"}]
Output for 7.1.20
1378912524 [1378912524,{"date":"2013-09-11 17:15:24.004016","timezone_type":3,"timezone":"Europe\/Amsterdam"}]
Output for 7.1.10
1378912524 [1378912524,{"date":"2013-09-11 17:15:24.029059","timezone_type":3,"timezone":"Europe\/Amsterdam"}]
Output for 7.1.7
1378912524 [1378912524,{"date":"2013-09-11 17:15:24.002686","timezone_type":3,"timezone":"Europe\/Amsterdam"}]
Output for 7.1.6
1378912524 [1378912524,{"date":"2013-09-11 17:15:24.011314","timezone_type":3,"timezone":"Europe\/Amsterdam"}]
Output for 7.1.5
1378912524 [1378912524,{"date":"2013-09-11 17:15:24.010357","timezone_type":3,"timezone":"Europe\/Amsterdam"}]
Output for 7.1.0
1378912524 [1378912524,{"date":"2013-09-11 17:15:24.006191","timezone_type":3,"timezone":"Europe\/Amsterdam"}]
Output for 5.4.30 - 5.4.45, 5.5.14 - 7.0.20
1378912524 [1378912524,{"date":"2013-09-11 17:15:24.000000","timezone_type":3,"timezone":"Europe\/Amsterdam"}]
Output for 5.4.0 - 5.4.29, 5.5.0 - 5.5.13
1378912524 [1378912524,{"date":"2013-09-11 17:15:24","timezone_type":3,"timezone":"Europe\/Amsterdam"}]
Output for 5.2.0 - 5.3.29
Fatal error: Interface 'JsonSerializable' not found in /in/FaXks on line 3
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/FaXks on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting '{' in /in/FaXks on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting '{' in /in/FaXks on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'{'' in /in/FaXks on line 3
Process exited with code 255.