fork download
  1. <?php
  2.  
  3. function create_date($format, $date) {
  4. $date = date_create_from_format($format, $date);
  5. if(DateTime::getLastErrors()['warning_count'] > 0) {
  6. echo 'error', PHP_EOL;
  7. }
  8. else {
  9. echo $date->format('d.m.Y'), PHP_EOL;
  10. }
  11. }
  12. create_date('d.m.Y', '31.2.1975');
  13. create_date('d.m.Y', '31.3.1975');
Success #stdin #stdout 0.02s 24296KB
stdin
Standard input is empty
stdout
error
31.03.1975