php detect and convert dates from a string

Viewed 2188

I was wondering if I could somehow to detect a date in a string and convert it into a standard date format.

Let's consider the input strings below:

Company registered on 16 March 2003

or

Activity between 10 May 2006 an 10 July 2008 - no changes.

Now I would like a PHP function to apply over the strings and get the dates as YYYY-mm-dd

Example:

$date = DateExtract($sting1); // output: 2003-03-16

$date = DateExtract($sting2); // output: ['2006-05-10','2008-07-10']

3 Answers
Related