3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Client { const SOLR_TIMEZONE = 'Zulu'; const SOLR_DATEFORMAT = 'Y-m-d\TG:i:s\Z'; public static function formatToSolrFormat(\DateTime $date) { $date = clone $date; $date->setTimezone(new \DateTimeZone(self::SOLR_TIMEZONE)); return $date->format(self::SOLR_DATEFORMAT); } } echo Client::formatToSolrFormat(new \DateTime());
Output for 5.3.0 - 5.5.9, 5.5.18 - 5.5.38, 5.6.1 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
2014-05-07T18:19:15Z
Output for 5.5.10 - 5.5.16, 5.6.0
Fatal error: Uncaught exception 'Exception' with message 'DateTimeZone::__construct(): Unknown or bad timezone (Zulu)' in /in/tErb8:11 Stack trace: #0 /in/tErb8(11): DateTimeZone->__construct('Zulu') #1 /in/tErb8(17): Client::formatToSolrFormat(Object(DateTime)) #2 {main} thrown in /in/tErb8 on line 11
Process exited with code 255.
Output for 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/tErb8 on line 8 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/tErb8 on line 11 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/tErb8 on line 17 2014-05-07T18:19:15Z
Output for 5.0.0 - 5.1.6
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/tErb8 on line 8 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/tErb8 on line 11 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/tErb8 on line 17 Fatal error: Class 'DateTime' not found in /in/tErb8 on line 17
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/tErb8 on line 5
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_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/tErb8 on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/tErb8 on line 5
Process exited with code 255.