I need to extract the date out of a string variable, and the date are formatted in various kind of formats as below:
$date1 = "03/12/2011 (Sat)";
$date2 = "3.12.2011 SAT";
$date3 = "Date: 03/12/2011 "; /* <-- the extra trailing space is intentional */
$date4 = "date:03/12/2011";
$date5 = "date: 03/12/2011";
$date6 = "03/12/2011";
$date7 = "13.12.2011 TUE";
What is the best way to create a PHP function which will work for all the input variables above in extracting the correct date info?
For more info on the DateTime object returned by the function, check the PHP documentation for the
DateTimeclass.