Home >Backend Development >PHP Tutorial >PHP generates a timestamp with a specified number of digits (13 digits)

PHP generates a timestamp with a specified number of digits (13 digits)

巴扎黑
巴扎黑Original
2016-11-23 11:28:453368browse

/**

*

* Returns a timestamp with a certain number of digits. The number of digits is determined by the parameter.

*

* @author Chen Bo

* @param type How many digits the timestamp has?

* @return Timestamp

*/

private function getTimestamp($digits = false) {

$digits = $digits > 10 ? $digits : 10;

$digits = $digits - 10;

if ((!$digits) || ($digits == 10))

{

return time();

}

else

{

return number_format(microtime(true),$digits,'','');

}

}


Statement:
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