preg_match()
Here is a function which I use to convert a date in the format of yyyy-mm-dd to a UNIX timestamp. Obviously, you'll need to modify this to suit your needs; it will be benificial to you if you look at the Pattern Syntax for PCRE too.
PHP Code:
/**
* Converts a date from FoxPro format to a UNIX time stamp.
*
* Converts a date in the format yyyy-mm-dd to a UNIX time stamp which can be used
* with PHP's date/time functions.
*
* @author Adam Delves (adam @ sccode . com)
* @copyright Copyright © all rights reserved Adam Delves
*
* @param string $date A date in the format yyyy-mm-dd
* @return mixed null for a null date or a timestamp for a valid date as returned by mktime()
*/
function format_date($date)
{
/* REGEXP: matches a stirng in the format dddd-dd-dd where
d is any decimal number 0-9
*/
$regex = "/^(\d{4})\-(\d{2})\-(\d{2})$/";
if ($date == '1899-12-30' || $date == '' ) { // empty/null date
return null;
} else if (preg_match($regex, $date, $matches)) {
return mktime(0,0,0, $matches[2], $matches[3], $matches[1]);
} else {
throw new Exception('Invalid Date Format'); // PHP 5 only
}
}