I think date_parse_from_format would be useful in some cases (specially in views date filters). Maybe it could be implemented in date api so other mouldes could use it; there is a simple implementation at PHP documentation:
function date_parse_from_format($format, $date) {
$dMask = array(
'H'=>'hour',
'i'=>'minute',
's'=>'second',
'y'=>'year',
'm'=>'month',
'd'=>'day'
);
$format = preg_split('//', $format, -1, PREG_SPLIT_NO_EMPTY);
$date = preg_split('//', $date, -1, PREG_SPLIT_NO_EMPTY);
foreach ($date as $k => $v) {
if ($dMask[$format[$k]]) $dt[$dMask[$format[$k]]] .= $v;
}
return $dt;
}
Comments
Comment #1
enboig commentedI have checked the function I posted from php.net and it didn't work as I expected. I written a new one, which can be extendend. To be more similar to the PHP5.3 one.
Comment #2
damienmckennaWe're sorry but the D6 release of Date module is no longer being supported. You are encouraged to update to Drupal 7 or 8, or direct questions to Drupal Answers.