- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试使用 timezone_name_from_abbr()
偏移量为 GMT+0800,但它不返回预期的时区:
echo "timezone =" . timezone_name_from_abbr('', 8 * 60 * 60, 0) . '<br/>';
根据文档,这应该有效:
If
abbr
doesn't exist then the time zone is searched solely by thegmtOffset
andisdst
.
我做错了什么? GMT+0800 是 Asia/Singapore
的有效时区。
最佳答案
这不是一个很花哨的答案,但它是一个已经存在了很长一段时间的错误 (Bug #44780 - some time zone offsets not recognized by timezone_name_from_abbr)。
基本上,这个特定的时区(和 some others )只会在您传递缩写时解析为名称,而不管文档怎么说。
顺便说一句,在函数无法解析名称的情况下,返回值为 false
。
关于PHP:为什么 timezone_name_from_abbr 不能使用 8 的 GMT 偏移量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17788650/
对于我用 PHP 构建的在线社区,我需要将默认时区设置为用户的时区。这是我现在的代码,它根据一些 JS 返回用户的时区偏移量: $timezone = $_SESSION['time']; $time
我需要一个完全相反的 timezone_name_from_abbr() 方法:http://php.net/manual/en/function.timezone-name-from-abbr.ph
我正在尝试使用 timezone_name_from_abbr()偏移量为 GMT+0800,但它不返回预期的时区: echo "timezone =" . timezone_name_from_ab
我是一名优秀的程序员,十分优秀!