I am posting data with dates in this format:
06/11/2015
i then use the below function to change the date format to insert into a database:
ChangeDateFormat('06/11/2015', 'Y-m-d');
date_default_timezone_set('Europe/London');
if(!function_exists("ChangeDateFormat")) {
function ChangeDateFormat($date = '', $format = '') {
if($date == '' or $date == '0000-00-00' or $date == '0000-00-00 00:00:00') {
return '-';
} else {
return date($format, strtotime($date));
}
}
}
but its inserting into the following format:
2015-06-11
whereas it should be 2015-11-06