i would like to convert a text date like "2012 July 11 16:00"
To a SQL conform date. (JJJJ-MM-DD)
I tried it with
Code: Select all
date('Y-m-d', strtotime('2012 July 11 16:00');
Code: Select all
date('Y-m-d', strtotime('2012 July 11 16:00');
Code: Select all
function switch_date($str)
{
//split string
$arr=explode(' ',$str);
//put in correct order
$new_str=$arr[2].$arr[1].$arr[0].$arr[3];
return date('Y-m-d', strtotime($new_str));
}