欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

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

程序员文章站 2022-04-18 21:09:46
...
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) 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...