Home > Backend Development > PHP Tutorial > How to get millisecond timestamp in PHP, get milliseconds in php_PHP tutorial

How to get millisecond timestamp in PHP, get milliseconds in php_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 09:57:07
Original
908 people have browsed it

How to get millisecond-level timestamps in PHP, get milliseconds in php

The example in this article describes how to get millisecond-level timestamps in PHP. Share it with everyone for your reference. The specific analysis is as follows:

PHP itself does not provide a function to obtain millisecond-level timestamps. It can be obtained through gettime(); in Java. If you want to perform high-precision millisecond-level docking communication with certain programs written in Java, you need to use PHP to output millisecond-level time. The method I took before was to use an imprecise method, which was to add a three-digit number after PHP's native time function. To obtain a more accurate millisecond-level timestamp, you can use the following code:

<&#63;php
function getMillisecond() {
list($t1, $t2) = explode(' ', microtime());
return (float)sprintf('%.0f',(floatval($t1)+floatval($t2))*1000);
}
echo getMillisecond();
Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/984615.htmlTechArticleHow to get millisecond timestamps in PHP, how to get milliseconds in php This article describes how to get millisecond timestamps in PHP . Share it with everyone for your reference. The specific analysis is as follows: PHP itself does not...
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template