3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $date = '28/05/1972'; $formats = [ 'dd/MM/yyyy', 'd/m/Y', ]; foreach ($formats as $format) { var_dump($format); $intlDateFormatter = new IntlDateFormatter( 'en_US', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/Los_Angeles', IntlDateFormatter::GREGORIAN, $format ); $intlDateFormatter->setLenient(false); $intlDateFormatter->parse($date); var_dump($intlDateFormatter->getErrorMessage()); //$intlDateFormatter->setLenient(true); $intlDateFormatter->parse($date); var_dump($intlDateFormatter->getErrorMessage()); } $fmt = new IntlDateFormatter( 'en_US', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/Los_Angeles', IntlDateFormatter::GREGORIAN, 'dd/MM/yyyy' ); echo 'lenient of the formatter is : '; if ($fmt->isLenient()) { echo 'TRUE'; } else { echo 'FALSE'; } $fmt->parse('35/13/1971'); echo "\n Trying to do parse('35/13/1971').\nResult is : " . $fmt->parse('35/13/1971');
based on ul9hk
Output for 5.6.0 - 5.6.30, hhvm-3.10.1 - 3.17.3, 7.0.0 - 7.2.0
string(10) "dd/MM/yyyy" string(12) "U_ZERO_ERROR" string(12) "U_ZERO_ERROR" string(5) "d/m/Y" string(12) "U_ZERO_ERROR" string(12) "U_ZERO_ERROR" lenient of the formatter is : TRUE Trying to do parse('35/13/1971'). Result is : 66038400
Output for 5.5.0 - 5.5.38
string(10) "dd/MM/yyyy" Fatal error: Class 'IntlDateFormatter' not found in /in/MjA8b on line 11
Process exited with code 255.