我按照此处概述的说明进行操作:
在 Mac 上的 XAMPP 上安装 PHP 国际化扩展 (Intl)
Ran sudo pecl install intl 从 Cellar 中选择了正确的文件
然后发生了这个错误:
/private/tmp/pear/temp/intl/intl_error.h:24:10:致命错误:找不到“ext/standard/php_smart_str.h”文件
包括
Run Code Online (Sandbox Code Playgroud)^ 1 error generated. make: *** [php_intl.lo] Error 1 ERROR: `make' failed
不管怎样,做了一些研究,发现 PHP 7.0.8 弃用了 php.smart_str.h 到 php.smart_string.h
因此,鉴于我对 C++ 的了解很少,我将 smart_string.h 复制到 smart_str.h 并将所有标头从 STRING 重命名为 string......
重新运行pecl - 不走运......更多错误......不知道.c文件在哪里并重新制作php(对走那么远并不真正感兴趣),因为无论如何我正在使用XAMPP所以结束了选项。
我的 mac 上有 php 5.5,位于 usr/local/bin 文件夹深处,所以下一步是让 pecl 使用这些文件并生成 intl.so 文件......
是吗....我有 intl.so 文件,因此将其放入 XAMPP 中的“扩展”文件夹中(以供参考:/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012 )
运行 php 并出现以下错误:
警告:PHP 启动:无法加载动态库 '/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012/intl.so' - dlopen(/Applications/XAMPP/xamppfiles/lib/ php/extensions/no-debug-non-zts-20151012/intl.so,9):找不到符号:_zval_used_for_init 引用自:/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts- 20151012/intl.so …
这不是一个重复的问题,但需要对时间有一点了解.
我需要一个以下问题的解决方案我有一些特定生产时间(基于日期),需要四舍五入到最接近的15秒:
60秒是1分钟意味着常规的圆形,地板,天花板是最接近的十进制(10/5),这对我没有时间帮助.因为我正在处理秒,所以可能是59:59将四舍五入到最接近的小时:例如17:59:59应该是18:00.
例:
6:17:29四舍五入到6:17:30 6:29:55四舍五入到6:30:00 20:45:34四舍五入到20:45:30
以下代码完成了一些工作:
$hr = date('H',($resultStr));
$mn = date('i',($resultStr));
$sc = date('s',($resultStr));
$tot = ($hr * 60 * 60) + ($mn * 60) + $sc;
$totd = $tot / (60);
$totc = ceil($totd);
$totc = $totc / 60;
$hr = floor($totc);
$mn = ($totc - $hr)*60;
$mnflr = floor($mn);
$mn2 = $mn - $mnflr;
echo "$hr:$mnflr";
Run Code Online (Sandbox Code Playgroud)
结果:18:35:17四舍五入到:18:36(这是错误的)18:31:49四舍五入到:18:32(这是错误的)
作为旁白:
$secs = date('U',($resultStr));
$round = ceil ( (($secs / 60 ) * 60 ));
$newtime = date('H:i:s',($round)); …Run Code Online (Sandbox Code Playgroud)