Created
June 22, 2013 05:39
-
-
Save acacha/5835996 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected function _convert_date_to_sql_date($date) | |
{ | |
$date = substr($date,0,10); | |
if(preg_match('/\d{4}-\d{2}-\d{2}/',$date)) | |
{ | |
//If it's already a sql-date don't convert it! | |
return $date; | |
}elseif(empty($date)) | |
{ | |
return ''; | |
} | |
$date_array = preg_split( '/[-\.\/ ]/', $date); | |
if($this->php_date_format == 'd/m/Y') | |
{ | |
$sql_date = date('Y-m-d',mktime(0,0,0,$date_array[1],$date_array[0],$date_array[2])); | |
} | |
elseif($this->php_date_format == 'm/d/Y') | |
{ | |
$sql_date = date('Y-m-d',mktime(0,0,0,$date_array[0],$date_array[1],$date_array[2])); | |
} | |
else | |
{ | |
$sql_date = $date; | |
} | |
return $sql_date; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment