且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Javascript - 检测用户的语言环境是否设置为使用12小时或24小时时间格式

更新时间:2023-02-26 16:20:17

只要Chromium不能修复 toLocaleString(),就没有办法用铬来做到这一点。



对于Firefox和IE解析, toLocaleString()会提供这些信息。
$ b 编辑


显然 toLocalString()现已在Chrome中修复。因此解析 toLocaleString()是个解决方案。


One way to do that is to parse new Date().toLocaleString(). But this doesn't work in chromium/webkit since the string it returns isn't dependent of the user's locale (see bug report at http://code.google.com/p/chromium/issues/detail?id=3607)

I emphasize that I'm looking for a solution that is client side only and that works in chromium.

As long as Chromium doesn't fix toLocaleString() there is no way to do that in chromium.

For Firefox and IE parsing toLocaleString() will give that information.

EDIT
Apparently toLocalString() is now fixed in Chrome. The parsing of toLocaleString() is therefore a solution.