Hi.
I have a form that submits a date (MM/DD/YYYY format). I need to save it in MySQL DATE (YYYY-MM-DD format).
How do I convert it?
I tried this, but something's wrong...
function ReformatDate($str)
{
// changes a given date (MM/DD/YYYY) to YYYY-MM-DD format
// that's needed because MySQL only likes it that way.
if (preg_match("/[0-9]{2}\\/{1}[0-9]{2}\\/{1}[0-9]{2,4}/",$str)) {
$dates = explode("/\\//",$str);
$str = $dates[2] . "-" . $dates[0] . "-" . $dates[1];
//echo "good " .$str;
return $str;
} else {
//echo "no good " .$str;
return $str;
}
}
I appriciate all the help (really!).
Thanks