Skip to content

Instantly share code, notes, and snippets.

@bhattisatish
Created May 1, 2010 06:57
Show Gist options
  • Save bhattisatish/386112 to your computer and use it in GitHub Desktop.
Save bhattisatish/386112 to your computer and use it in GitHub Desktop.
function parse_to_date_and_string($parse) {
$exclude = array('i', 'at');
$parse_array = explode(" ", $parse);
$date = array();
$data['text'] = array();
$word_count = count($parse_array);
for($i = 0; $i < $word_count; $i++) {
if (strtotime($parse_array[$i]) > 0 && !in_array($parse_array[$i], $exclude)) {
$date[] = $parse_array[$i];
} else {
$data['text'][] = $parse_array[$i];
}
}
$data['date'] = strtotime(implode(" ", $date));
return $data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment