I'm trying to make it so that if a date is entered in a certain format its converted to the format compatible with mysql. So far i have it able to convert the following formats YYYY-MM-DD YYYY/MM/DD DD-MM-YYYY DD/MM/YYYY YY-MM-DD I'm struggling to get it to convert DD-MM-YY Can anyone help. The code i have so far is
function date_convert($var) { list($day, $month, $year) = explode("/", $var); return implode("-", array($year, $month, $day)); } PHP: Enjoy!