1 second = millisecond = 1000,000 microsecond = 1000,000,000 nanosecond
PHP has no default function for milliseconds, but it provides a microtime () function that returns two elements, one for seconds, and one for fractional milliseconds, which makes it easy to define a function that returns a number of milliseconds, for example:
/* Get time difference, millisecond * /function get_subtraction () { $t 1 = microtime (true); $t 2 = Microtime (true); Return (($t 2-$1) *1000). ' Ms '; }
/ * * microsecond microseconds millisecond milliseconds * Returns the number of milliseconds for the timestamp */ function Get_millisecond () { list ($ USEC, $sec) = Explode ("", Microtime ()); $msec =round ($usec *1000); return $msec; } /* * * returns the number of milliseconds in a string time stamp */ function Get_total_millisecond () { $time = explode ("", Microtime ()); $time = $time [1]. ($time [0] * +); $time 2 = Explode (".", $time); $time = $time 2 [0]; return $time; } /* * returns the current Unix timestamp and the number of microseconds (in fractional seconds) of floating-point numbers, commonly used to calculate code snippet execution Time * /function microtime_float () { List ($usec, $sec) = Explode ("", Microtime ()); return (float) $usec + (float) $sec); }