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(); } } ?>

preferences:
23.8 ms | 404 KiB | 5 Q