i am taking date input from user in a form . User will enter date in mm-dd-yyyy but mysql supports yyyy-mm-dd . Now what is way to change input date to mysql standard format . Like to_date(format,date) function in oracle.
the easiest way is to use the substr function. Something like
$new_date = substr($old_date,6,4)."-".substr($old_date,3,2)."-".substr($old_date,0,2)
or, even easier (or at least easier to understand):
list($month,$day,$year) = explode('-', $olddate); $new_date = $year.'-'.$month.'-'.$day;