date时间格式转毫秒时间戳和获取当前毫秒时间戳php


//获取当前时间戳(毫秒的)

function msectime() {
    list($msec, $sec) = explode(' ', microtime());
    $msectime =  (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000);
    return $msectime;
  }


//时间格式转毫秒时间戳

/** 时间日期转时间戳格式,精确到毫秒,
  *     
  */
$time = '2018-9-15 1:1:1';
 function get_data_format($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;
 }

 

你可能感兴趣的:(TP,PHP,PHP接口)