'YYYY/MM/DD', '\d{4}\-\d{2}\-\d{2}'=>'YYYY-MM-DD', '\d{4}\/\d{2}\/\d{2}\s\d{2}:\d{2}'=>'YYYY/MM/DD HH24:MI', '\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}'=>'YYYY-MM-DD HH24:MI:SS', '\d{4}\/\d{2}\/\d{2}\s\d{2}:\d{2}:\d{2}'=>'YYYY/MM/DD HH24:MI:SS', '\d{4}\-\d{2}\-\d{2}T\d{2}:\d{2}:\d{2}'=>'YYYY-MM-DD"T"HH24:MI:SS', '\d{4}\-\d{2}\-\d{2}T\d{2}:\d{2}:\d{2}Z'=>'YYYY-MM-DD"T"HH24:MI:SS"Z"', ]; $format=false; foreach($formats as $rgx=>$ociFormat){ if(preg_match("/$rgx/", $dateStr)) $format=$ociFormat; } return $format; } // retourne une fonction "to_date" sql complète en fonction d'une string de date public static function dateStrToToDate($dateStr){ $format=self::guessFormatMask($dateStr); if($format) $format="TO_DATE('$dateStr','$format')"; return $format; } public static function toSQL($Str=''){ return str_replace("'","''",trim($Str)); } }