3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str_date = '12.31.2018'; try{ if($valid = (new \DateTime($str_date))){ echo $valid->getTimeStamp(); } } catch(Exception $e){ try { $str_date = (str_replace('.','/',$str_date)); if($valid = (new \DateTime($str_date))){ echo $valid->getTimeStamp(); } } catch(Exception $e){ echo $e->getMessage(); } } ?>
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.27, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
1546210800
Output for 7.3.32 - 7.3.33, 8.0.13
1546214400

preferences:
43.07 ms | 406 KiB | 5 Q