Home >Backend Development >PHP Tutorial >PHP generates a timestamp with a specified number of digits (13 digits)
/**
*
* 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,'','');
}
}