我在 Chrome 上看到了这样的行为,其中将 hours12 设置为 true 格式的中午 12:00 时间的返回值显示为下午 0 点。不应该是12吗?如果不是,显示 12 小时时钟的正确方法是什么?请注意,我只能使用 ES5。
Chrome 中的以下内容打印 0 pm:
var foo = new Date(2020, 0, 1, 12, 0, 0)
var bar = new Intl.DateTimeFormat("en-GB", {hour12: true, hour: "numeric"}).format(foo)
console.log(bar)Run Code Online (Sandbox Code Playgroud)
请注意,bar 的值为“0 pm”。除 en-GB 之外的其他语言也表现出这种行为。不过,使用 en-US 运行相同的代码却给出“12 PM”。难道英国人和其他人实际上用“0 pm”来表示中午?这是 Chrome 中的错误吗?在 FF 或 IE 中不会发生这种情况。
预先感谢您的任何意见。