I've come across this in my companies code base, and I'd like to change it to something that doesn't connect to mysql just to just a function:

```
$sql = "select date_format(str_to_date('$date','$format'),'%Y-%m-%d') startDate ";
$result = mysql_query($sql);
...

```

Our production env is of the unix variety, as is my dev environment, but some people write code on a windows environment, so `strptime()` isn't an option.

I've seen similar questions floating around SO, but none with an answer that fits my needs. Is there a simple, or common way to extract dates from strings using a variable format?

The reason the date formats can vary so much is because we're parsing file names from vendors, so we have to be able to handle yyyymmdd, mmddyyyy, ddmmyyyy, ddmonyyyy, etc, etc.