1、获取时间,格式如:yyyyMMddHHmmssSSSZ。//获取当前时间秒数function get_millisecond(){ list($usec, $sec) = explode(" ", microtime()); $msec=round($usec*1000); return $msec;}$cn_time=date('YmdHis', time()).get_millisecond();$jhm=$cn_time."+0800";echo $jhm;//20160105053335921+0800
2、将yyyyMMddHHmmssSSSZ时间格式转换为Y-m-d H:i:s等格式倦虺赳式。第一种:$dateStr="20151221100259308+0800";$times=strstr($dateStr, '+', TRUE);$a=substr($times,0,-3);$tt=strtotime($a);echo date("Y-m-d H:i:s",$tt);//2015-12-21 10:02:59第二种:$dateStr="20151221100259308+0800";$date=preg_replace('{^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(.*?)$}u', '$1-$2-$3 $4:$5:$6', $dateStr);echo $date;//2015-12-21 10:02:59