js Date toLocaleString [英] js Date toLocaleString

查看:135
本文介绍了js Date toLocaleString的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用3个浏览器来输出这个结果。

I use the 3 browsers to output this result.

Chrome:

new Date().toLocaleString()
> "Sun Sep 04 2011 21:40:04 GMT+0800 (HKT)"

Safari: p>

Safari:

new Date().toLocaleString()
> "2011年9月4日 下午09时54分51秒格林尼治标准时间+0800"

new Date().toLocaleString()
> "Sun Sep 4 21:46:03 2011"

为什么不一样的输出结果?时间缩放

why not the same output result? timezoom?

推荐答案

这取决于计算机的配置,用户的首选日期格式,显然是用户的区域设置,以及浏览器如何确定这个。

It depends on the configuration of the computer, the user's preferred date format, obviously the user's locale, and how the browser determines this.

您应该更喜欢使用适当的日期库,例如 datejs 格式化。

You should really prefer using a proper date library such as datejs for formatting.

查看他们的 Date.toString() 格式说明符

See their Date.toString() and format specifiers.

这篇关于js Date toLocaleString的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆