It takes a microsecond, but I find that the number of digits is not long or short.

Source: Internet
Author: User
Get the time in microseconds, but I found out how the number of digits suddenly grows or decreases. public function getmicrotime ()
{
List ($ usec, $ sec) = explode ("", microtime ());
// Return (float) $ usec + (float) $ sec );
Return date ('ymdhis '). $ usec * 1000000;
}


I used the order number precise to microseconds. But I find that there is only one missing person. what is the problem.
Thank you.


Reply to discussion (solution)

You just $ usec * 1000000
What if $ usec equals 0.0012345?
Isn't it 1 million if it is increased by 12345 times? The preceding values are not 0.

List ($ usec, $ sec) = explode ("", microtime ());
Return date ('ymdhis ', $ sec). substr ($ usec, 2 );

Format the number and determine the number. if not, add 0.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.