The difference between time(), date(), and microtime()

time() returns the current unix timestamp
date() formats a local time/date
microtime() returns the current unix timestamp and microseconds

Difference 1
When there is no parameter,
(1) The result returned by microtime() is a string in the format of "msec sec", where sec (timestamp) is since the Unix epoch (0:00:00 January 1, 1970 GMT) the number of seconds since the present, msec is the microsecond part. The value returned by microtime(true) is the sum of sec+msec, with four decimal places.
The return value type of microtime() is string(21), and the return value type of microtime(true) is float.
(2) date() is the default time is time().
(3) time() is the number of seconds since the Unix epoch (0:00:00 January 1, 1970 GMT), and the value is the same as the sec value of micrtime().
The difference between
microtime() and time() is also different in application. time() is formatted by date(), and its value is the current time of the system.
microtime() is mostly used as part of the initialization of the random number function mt_srand() to seed the random number generator.

Please refer to the manual for the usage of the three functions. No explanation is given here.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326127866&siteId=291194637