PHP毫秒级别之间的互相转换

/**

  • 获取毫秒级别的时间戳
    */
    public function getMsecTime()
    {
    list($msec, $sec) = explode(’ ', microtime());
    m s e c t i m e = ( f l o a t ) s p r i n t f ( ′ msectime = (float)sprintf('%.0f', (floatval( msectime=(float)sprintf(msec) + floatval($sec)) * 1000);
    return $msectime;
    }

/**

  • 毫秒转日期
    */
    public function getMsecToMescdate($msectime)
    {
    $msectime = m s e c t i m e ∗ 0.001 ; i f ( s t r s t r ( msectime * 0.001; if(strstr( msectime0.001;if(strstr(msectime,’.’)){
    sprintf("%01.3f", m s e c t i m e ) ; l i s t ( msectime); list( msectime);list(usec, s e c ) = e x p l o d e ( " . " , sec) = explode(".", sec)=explode(".",msectime);
    s e c = s t r p a d ( sec = str_pad( sec=strpad(sec,3,“0”,STR_PAD_RIGHT);
    }else{
    $usec = $msectime;
    $sec = “000”;
    }
    d a t e = d a t e ( " Y − m − d H : i : s . x " , date = date("Y-m-d H:i:s.x", date=date("YmdH:i:s.x",usec);
    return $mescdate = str_replace(‘x’, $sec, $date);
    }

/**

  • 日期转毫秒
    */
    public function getDateToMesc(KaTeX parse error: Expected '}', got 'EOF' at end of input: …cdate) { list(usec, $sec) = explode(".", $mescdate);
    d a t e = s t r t o t i m e ( date = strtotime( date=strtotime(usec);
    r e t u r n d a t a = s t r p a d ( return_data = str_pad( returndata=strpad(date.$sec,13,“0”,STR_PAD_RIGHT);
    return $msectime = $return_data;
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值