As you've now wrote that you do not have PHP 5.3 at hand (really a pity), so you need to parse the string "by hand". Next to PCRE regular expressions, there is also sscanf. Example:
$date = 'September 24, 2012';
$result = sscanf($date, '%s %2d, %4d', $month, $day, $year);
$parsed = array(
'day' => $day,
'month' => $month,
'year' => $year
);
var_dump($parsed);
Output:
array(3) {
'day' =>
int(24)
'month' =>
string(9) "September"
'year' =>
int(2012)
}
This will already parse the input date string according to your format. If you need this more flexible, the pattern needs to be built dynamically, as well as associating the values to the result array.
I've compiled another example that does this. It might be a little fragile (I've added some notes), however it does work. Naturally I would wrap this into a function an better deal with the error conditions but I've keep the code raw, so that it better shows how it works:
// input variables:
$date = 'September 24, 2012';
$format = 'F j, Y';
// define the formats:
$formats = array(
'F' => array('%s', 'month'), # A full textual representation of a month, such as January or March
'j' => array('%2d', 'day'), # Day of the month, 2 digits with or without leading zeros
'Y' => array('%4d', 'year'), # A full numeric representation of a year, 4 digits
# NOTE: add more formats as you need them
);
// compile the pattern and order of values
$pattern = '';
$order = array();
for($l = strlen($format), $i = 0; $i < $l; $i++) {
$c = $format[$i];
// handle escape sequences
if ($c === '\\') {
$i++;
$pattern .= ($i < $l) ? $format[$i] : $c;
continue;
}
// handle formats or if not a format string, take over literally
if (isset($formats[$c])) {
$pattern .= $formats[$c][0];
$order[] = $formats[$c][1];
} else {
$pattern .= $c;
}
}
// scan the string based on pattern
// NOTE: This does not do any error checking
$values = sscanf($date, $pattern);
// combine with their names
// NOTE: duplicate array keys are possible, this is risky,
// write your own logic this is for demonstration
$result = array_combine($order, $values);
// NOTE: you can then even check by type (string/int) and convert
// month or day names into integers
var_dump($result);
The result in this case then is:
array(3) {
'month' =>
string(9) "September"
'day' =>
int(24)
'year' =>
int(2012)
}
Take care of the notes. Before I wrote it, I've checked the user-notes in the PHP manual, but the functions offered there are only for parsing one specific pattern, whereas this variant should be extensible to a certain degree. If you only have that one format, you can naturally create the sscanf string non dynamically.
See also: date_create_from_format equivalent for PHP 5.2 (or lower)
Also take care that as this is wordpress, the month names might be translated.
And I'm pretty sure you can get the date of a post also in timestamp format. For a plugin it might be less burdensome to just aquire that value based on the post ID instead of parsing some string.
And a final note: Only Wordpress has a minimum PHP version, it must not mean your plugin needs that exact minimum version, too. Especially in the case you outline, PHP 5.2 does not get any support any longer (it's dead), and you could do your plugins users the favor to tell them that they should update their PHP version.
It looks like that Wordpress still misses to give warnings about the PHP version, they stop with browsers and their own software somehow ;) There is no need to mimic that bad practice. Tell your users that they are in danger and scare the hell out of them (or do shiny popup-bubbles to get the message over in a less threatening way. Do your users a service with good intentions, then there is something to win for both sides, do some kind of graceful fallback to show your good attitude).
See also: Is there a Wordpress version that is incompatible with PHP 5.3?
You find the current release cycle of PHP outlined on PHP.net: https://wiki.php.net/rfc/releaseprocess if you're interested.
DATETIME, then format it at retrieval time, but don't save it in custom format - how about making a date-based query?