浮动到 UNIX 纪元
我正在从一个 JSON 数据库中提取数据,该数据库存储了 unix 纪元中的时间,但由于某种原因,当我提取它们时,数字会浮动。这是我以前从未遇到过的事情。因此,基本上像 1293083730000
这样的数字显示为 1.293085408E+12
我需要将数字返回到纪元时间,以便我可以将其与当前时间进行比较。任何帮助都会很棒。
I am pulling data from an JSON database that is storing the time in unix epoch but for some reason the numbers are being floated when I'm pulling them out. This is something I've never had to deal with before. So basiclly a number like 1293083730000
is showing up as 1.293085408E+12
I need to get the number back to the epoch time so I can compare it to the current time. Any help would be great.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是工程表示法,一种书写大数的便捷方法。该数字仍然是整数。
问题是 PHP 的内部类型太小,无法将数字表示为小数,请参见以下示例:
此输出:
您需要 64 位平台,或者将数字作为字符串或浮点值使用。有关更多详细信息,请参阅有关整数的 PHP 文档:
http://php.net/manual /en/language.types.integer.php
That's engineering notation, a convenient method of writing large numbers. The number is still an integer.
The problem is is that PHP's internal types are too small to represent the number as a decimal, see the following example:
This outputs:
You need either a 64-bit platform or work with the number as a string or floating point value. See the PHP documentation on Integers for more details:
http://php.net/manual/en/language.types.integer.php
在
php.ini
配置文件中,有一个值' precision'
。它只是定义了浮点数中将显示多少位数字。
更多信息请参见 PHP 手册
您可以提高精度值并重试。
In the
php.ini
configuration file, there is a value'precision'
.It simply defines how many digits will be shown in a float number.
More informations in PHP manual
You can increase the precision value and try again.