I might be going at this with the wrong tools, so feel free to tell me there's a better way to do it.

I need to extract dates from a string of text, alter the dates and then recompile the string. Here is an example string: DateCreated <= '2009-05-01' AND DateUpdated.

My thought is that if I can create a pattern for 'YYYY-MM-DD' then I could extract the data I need using a regular expression. From there I can convert the extracted string to a date, do my calculation, convert it back to a string and compile the pieces of the array back together with the updated date.

The problem is that I'm utterly confused when it comes to the actual PHP functions in terms of extracting the string and even more so when it comes to creating the pattern to fit 'YYYY-MM-DD' as a date. Has anyone ever done this before or could you point me in the direction of a good tutorial? Everything I manage to find online is a bit over my head and they jump right into complicated examples.