/ Published in: PHP
This snippet collects a date from a var and formats it into the correct format for database date entry
Expand |
Embed | Plain Text
//date from a form in the format of dd/mm/yyyy $var_day = $date_array[0];//day seqment $var_month = $date_array[1];//month segment $var_year = $date_array[2];//year segment $departure = "$var_year-$var_day-$var_month";//join them all together to input into a mysql table
Comments
Subscribe to comments
You need to login to post a comment.

Spotted a mistake the last line should be: $date= "$varyear-$varday-$var_month";//join them all together to input into a mysql table
MySQL date format is yyyy-mm-dd. Also, you should check if the date is correct.
function date_mysql($str) { list($day, $month, $year) = explode('/', $str);}