Hey all.
I was wondering if anyone knew of where I could find a regular expression that would match any date that is acceptable by strtotime().
Here is what I have so far (not complete by any means):
This will match any of the following:PHP Code:
'#((([0-3]?[0-9](st|nd|rd|th)?
)?(Jan(uary)?|Feb(ruary)?|Mar(ch)?|Apr(il)?|May|Ju((ly?)|
(ne?))|Aug(ust)?|Oct(ober)?|(Sept|Nov|Dec)(ember)?)
)?(18|19|20)[0-9]{2})#i'
21 Aug 1998
Aug 1998
1998
21st August 1998
... And any combination of variations you can think of in there.
The problem is, strtotime() can take MANY more date formats and I want to be able to match all of them and I'm not too skilled at regular expressions. I could probably come up with one, but it would be miles long just to account for every case. I'm sure someone else could come up with a more elegant one.
Any ideas?




Reply With Quote