php 日期转换成日时截
private function toTimeStamp ($dateTimeString = NULL) {
if (!$dateTimeString) {
$dateTimeString = time();
}
$numeric = '';
$add_space = false;
for($i=0;$i<strlen($dateTimeString);$i++) {
if(strpos('0123456789',$dateTimeString[$i])===false) {
if($add_space) {
$numeric .= ' ';
$add_space = false;
}
} else {
$numeric .= $dateTimeString[$i];
$add_space = true;
}
}
$numeric_array = explode(' ',$numeric,6);
if(sizeof($numeric_array)<3 || ($numeric_array[0]==0 && $numeric_array[1]==0 && $numeric_array[2]==0)) {
throw new Exception($dateTimeString . ' is an invalid parameter', 5);
} else {
$result = mktime(intval($numeric_array[3]), intval($numeric_array[4]), intval($numeric_array[5]),
intval($numeric_array[1]), intval($numeric_array[2]), intval($numeric_array[0])) ;
}
return $result;
}