我正在使用 jQuery 的 flot 图形库,它对任何时间序列都使用 javascript 时间(提醒一下,这是自 1970 年 1 月以来的毫秒数。Unix 时间是秒)。
我当前的代码如下所示:
foreach($decoded['results'] as $currentResult) {
if($currentResult['from_user'] == $user) {
$strippedTexts = $currentResult['created_at'];
$dates []= strtotime($strippedTexts);
}
}
这给了我一组 Unix 时间戳。我想在循环中为 JavaScript 准备数据,但是当我尝试时
$dates []= 1000*strtotime($strippedTexts);
数字太大,它会输出“[-2147483648]”。我是否需要将数组中允许保存的变量的“类型”更改为 bignum 或其他内容?
谢谢!
最佳答案
试试这个:
$dates []= 1000.0*strtotime($strippedTexts);
这会将其转换为 float,在 php 中它可以存储比 int 更大的数字。
关于php - Unix 时间戳和 JavaScript 时间;太大!,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/761734/