用php创建3位毫秒 [英] Create 3 digit Millisecond with php

查看:632
本文介绍了用php创建3位毫秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有13位数字,想要创建日期和时间,包含毫秒

I have 13 digit number and want to create date and time with include milisecond

示例代码就是这样,这是我的php脚本

Example code is like this this is my php script

$mil = 1328910295939;
$seconds = $mil / 1000;
$showdate = date('Y:m:d H:i:s', $seconds) ;

echo "$showdate";

结果是这样的2012:02:10 15:44:55.xxx ===> xxx是我想显示的3位数毫秒。

the result is like this 2012:02:10 15:44:55.xxx ===> xxx is 3 digit miliseconds that i want to show up.

以及如何在H:i:s之后以3位数毫秒显示

and how to include with 3 digit milisecond after H:i:s

请帮助我.....

推荐答案

这样的东西怎么样? b
$ b

How about something like this?

$mil = 1328910295939;

function toTimestamp($milliseconds)
{
    $seconds = $milliseconds / 1000;
    $remainder = round($seconds - ($seconds >> 0), 3) * 1000;

    return date('Y:m:d H:i:s.', $seconds).$remainder;
}

echo toTimestamp($mil);

Tadaa!

应该很漂亮

此外,这是输出: 2012:02:10 15:44:55.939 - 为什么你没有使用 - 分隔日期部分打败我。

Also, this is the output: 2012:02:10 15:44:55.939 - why you're not using - for delimiting the date portion beats me.

这篇关于用php创建3位毫秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆