I’m looking to pull out any dates from my story. I assume I’ll do strpos to see if there’s any dates but given there’s so many variations around format. How could I design a needle or a few common needles?
@kiwisauthorDec 29.2021 — #One common format seems to be day of week, day of month followed by month.
Friday 13 May
Friday 13th May
I could do pre_match any work ending day, followed by 1 or 2 digits followed by a work between 3 and 6 letters May & September. A second pattern could include st, th, rd
Another option is looking for reference to a day, say Tuesday, but I'd need to see reference to ''kickoff' a few works either side. The I could strtotime('this tuesday'). But I'm not sure how to check works either side.
@NogDogDec 29.2021 — #You'd want to use preg_match_all() for that, most likely. But if you have no control over what formats are used in the text, you're going to have to come up with a lot of patterns, plus figure out how to tell if 10/11/2012 is October 11 or November 10 (if it matters?). Just the various number-only formats are numerous, without even delving into dealing with month names and abbreviations.