I am trying to convert a date into a different format, but when I do I always get 1970-01-01. Below is a copy of my code.
$courseDate = $_SESSION['get_course_date']; //value returns '17/03/2014 - Standard Course'
$regex='((?:(?:[0-2]?\\d{1})|(?:[3][01]{1}))[-:\\/.](?:[0]?[1-9]|[1][012])[-:\\/.](?:(?:[1]{1}\\d{1}\\d{1}\\d{1})|(?:[2]{1}\\d{3})))(?![\\d])';
if ($c=preg_match_all ("/".$regex."/is", $courseDate, $matches)){ //use regex to get just he date
$get_date=$matches[1][0]; // returns 17/3/2014
echo date('Y-m-d', $get_date); // output 1970-01-01
}
Any feedback would be great.
Cheers