Search code examples
phpregexdatetext-extraction

Extract "M d, Y" formatted date expression from string


My webpage looks like this

<h3>Headline</h3>

      Unimportant Nov 20, 2012<br />

I just want to get the date and format it for new DateTime.


Solution

  • ([A-Za-z]{3} [012]\d, [12](\d){3})
    

    Should do the trick. This will catch any date with the format you provided.