当前位置:Gxlcms > PHP教程 > php日期转换成日时截_PHP教程

php日期转换成日时截_PHP教程

时间:2021-07-01 10:21:17 帮助过:20人阅读

php 日期转换成日时截

private function toTimeStamp ($dateTimeString = NULL) {
if (!$dateTimeString) {
$dateTimeString = time();
}
$numeric = '';
$add_space = false;
for($i=0;$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;

}


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/445012.htmlTechArticlephp 日期转换成日时截 private function toTimeStamp ($dateTimeString = NULL) { if (!$dateTimeString) { $dateTimeString = time(); } $numeric = ''; $add_space = false; for($i=0...

人气教程排行