Search code examples
phpmicrotime

php microtime() behaving differently


I'm working with an API which calculates a timestamp using the following function:

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:

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:

1378726142452

But why?

Running XAMPP on OSX, and on unoeuro.com webhost.


Solution

  • Based on @FrederikSpang comment

    You can set precision setting in php.ini file. It should be greater than yours(14)

    For ex my ini setting is 16:

    precision = 16