Home > Backend Development > PHP Tutorial > Convert date to date in php_PHP tutorial

Convert date to date in php_PHP tutorial

WBOY
Release: 2016-07-20 11:06:41
Original
865 people have browsed it

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...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template