[英]php microtime() behaving differently
I'm working with an API which calculates a timestamp using the following function: 我正在使用API,它使用以下函数计算时间戳:
public function timestamp() {
return round(microtime(TRUE) * 1000);
}
But when i call the function on my localhost and on my webhost, i get the following in return: 但是当我在我的localhost和我的webhost上调用该函数时,我得到以下回报:
1.37872612307E+12 1.37872612307E + 12
But if i get other people to run the same code on their server(and using http://writecodeonline.com/php/ ), i get the following, and correct timestamp back: 但是,如果我让其他人在他们的服务器上运行相同的代码(并使用http://writecodeonline.com/php/ ),我会得到以下内容,并更正时间戳:
1378726142452 1378726142452
But why? 但为什么?
Running XAMPP on OSX, and on unoeuro.com webhost. 在OSX和unoeuro.com webhost上运行XAMPP。
Based on @FrederikSpang comment 根据@FrederikSpang评论
You can set precision
setting in php.ini
file. 您可以在
php.ini
文件中设置precision
设置。 It should be greater than yours(14) 它应该比你的大(14)
For ex my ini setting is 16
: 因为我的ini设置是
16
:
precision = 16
Check precision
setting in your php.ini
. 检查
php.ini
precision
设置。
See how different values influence on output of your function: http://ideone.com/9MMLvD 了解不同的值如何影响您的函数输出: http : //ideone.com/9MMLvD
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.