fork(1) download
  1. <?php
  2.  
  3. $someString = "2014-01-01 12:00:01'; select * from users;";
  4.  
  5. $date = date_parse($someString);
  6. if (checkdate($date["month"], $date["day"], $date["year"]))
  7. echo "Valid date\n";
  8. else
  9. echo "Invalid date\n";
  10.  
  11.  
  12. echo var_dump($date);
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
Valid date
array(13) {
  ["year"]=>
  int(2014)
  ["month"]=>
  int(1)
  ["day"]=>
  int(1)
  ["hour"]=>
  int(12)
  ["minute"]=>
  int(0)
  ["second"]=>
  int(1)
  ["fraction"]=>
  float(0)
  ["warning_count"]=>
  int(1)
  ["warnings"]=>
  array(1) {
    [31]=>
    string(29) "Double timezone specification"
  }
  ["error_count"]=>
  int(6)
  ["errors"]=>
  array(6) {
    [19]=>
    string(20) "Unexpected character"
    [20]=>
    string(20) "Unexpected character"
    [22]=>
    string(47) "The timezone could not be found in the database"
    [29]=>
    string(20) "Unexpected character"
    [36]=>
    string(29) "Double timezone specification"
    [41]=>
    string(20) "Unexpected character"
  }
  ["is_localtime"]=>
  bool(true)
  ["zone_type"]=>
  int(0)
}