if date 2013-04-05 has format yyyy-mm-dd and 05/10/2013 has format dd-mm-yyyy you can use:
2013-04-05 => 05/10/2013
$date = implode('/', array_reverse(explode('-', '2013-04-05')));
05/10/2013 => 2013-04-05
$date = implode('-', array_reverse(explode('/', '05/10/2013')));
If you have other date format - here is more flexible functions
// if $date = '05/10/2013' (mm-dd-yyyy) e.g.
function dateToMysql($date, $format = 'd-m-Y') {
$date = explode('/',$date);
return date($format, strtotime($date[1]."-".$date[0]."-".$date[2]));
}
// if $date = '2013-04-05' (yyyy-mm-dd) e.g.
function mysqlToDate($date, $format = 'm/d/Y') {
$date = explode('-',$date);
return date($format, strtotime($date[0]."-".$date[1]."-".$date[2]));
}