当前位置:网站首页>PHP gets the current timestamp three bit MS MS timestamp

PHP gets the current timestamp three bit MS MS timestamp

2022-07-23 13:36:00 Rudon Binhai fishing village

<?php

    /**
     *  Get the current three digit number of milliseconds  -  character string   or   Integers 
     * 
     * @param boolean $return_number  Whether to return milliseconds of positive integer type , Default false
     * 
     * @return string|int   Number of milliseconds 
     */
    function get_current_3_digit_millisecond ( $return_number = false ) {
        //  Get the millisecond string  +  Integer timestamp 
        // "0.04009600 1658461202"
        list($ms, $timestamp) = explode(' ', microtime());

        //  Determine whether to return string format 
        if ($return_number) {
            //  Integers 
            $res = intval(substr($ms, 2, 3));

        } else {
            //  character string 
            $res = substr($ms, 2, 3);
        }

        return $res;
    }




    //  Example 
    $nums = get_current_3_digit_millisecond();
    var_dump($nums); // "040"

原网站

版权声明
本文为[Rudon Binhai fishing village]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/204/202207230635247541.html