p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #ba2da2; background-color: #ffffff }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #008400; background-color: #ffffff }
p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff }
p.p4 { margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; background-color: #ffffff; min-height: 14.0px }
p.p5 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #272ad8; background-color: #ffffff }
span.s1 { color: #ba2da2 }
span.s2 { color: #008400 }
span.s3 { color: #272ad8 }
span.s4 { color: #d12f1b }
span.s5 { color: #000000 }
<?PHP /* * Created on 2018-03-12 毫秒级时间 * Programmer : andy * Develop a project PHP - MySQL - Apache */ namespace Common\Model; class MsecTimeModel { /** * desc 返回当前的毫秒时间戳 */ function getMsectime() { list($msec, $sec) = explode(‘ ‘, microtime()); $msectime = (float)sprintf(‘%.0f‘, (floatval($msec) + floatval($sec)) * 1000000); return $msectime; } /** *desc 时间戳 转 日期格式 : 精确到毫秒,x代表毫秒 */ function getMicrotimeFormat($time) { $time=$time*0.000001; if(strstr($time,‘.‘)){ sprintf("%01.6f",$time); //小数点。不足6位补0 list($usec, $sec) = explode(".",$time); $sec = str_pad($sec,6,"0",STR_PAD_RIGHT); //不足6位。右边补0 }else{ $usec = $time; $sec = "000000"; } $date = date("Y-m-d H:i:s.x",$usec); return str_replace(‘x‘, $sec, $date); } /** * @desc 时间日期转时间戳格式,精确到毫秒 */ function getDataFormat($time) { list($usec, $sec) = explode(".", $time); $date = strtotime($usec); $return_data = str_pad($date.$sec,13,"0",STR_PAD_RIGHT); //不足13位。右边补0 return $return_data; } /** *desc 获取当前时间 精确到秒 */ function getCurrenMsecTime() { return $this->getMicrotimeFormat($this->getMsectime()); } /** *desc 时间毫秒级改为到秒 */ function getTimeByMsecTime($MsecTime) { $time=strtotime($MsecTime); if(empty($MsecTime) or $MsecTime==null or $time==0) return ‘0000-00-00 00:00:00‘; return date(‘Y-m-d H:i:s‘,$time); } } ?>
原文地址:https://www.cnblogs.com/fyandy/p/8688154.html
时间: 2024-10-27 09:29:41