function date_to_mysql($date) {
//if $date is not numeric, assume it's in textual format
if (!is_numeric($date)) {
$date=strtotime($date);
}
return date('Y-m-d H:i:s',$date);
}
Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/RaQnDGMQ8Nc/12883