javascript - 默认的 Date.toLocalDateString() 基于什么?
问题描述
我正在尝试本地化我的 Web 应用程序,并且我考虑在我的前端脚本上使用 Date.toLocalDateString() ,因此它将基于用户位置。
根据 Mozzila MDN:
在不指定语言环境的基本使用中,返回默认语言环境和默认选项的格式化字符串。
他们提供了这个代码示例:
var date = new Date(Date.UTC(2012, 11, 12, 3, 0, 0));
// toLocaleDateString() without arguments depends on the implementation,
// the default locale, and the default time zone
console.log(date.toLocaleDateString());
// → "12/11/2012" if run in en-US locale with time zone America/Los_Angeles
但它没有说明默认语言环境和默认时区来自哪里。是按照系统设置吗?浏览器设置?知识产权?如果用户使用 VPN,它会改变吗?
解决方案
推荐阅读
- sql-server - 将 MS ACCESS 数据库表导入 SQL Server
- typescript-typings - 在 Typescript 中使用带有 Record 的泛型类型
- c++11 - 尝试包含来自同一项目的标头时出现未定义的引用错误
- authentication - Kibana 不显示用户,并且不允许管理用户/角色
- python - 我如何计算积分?
- pyspark - 基于其他列将新列添加到 pyspark 数据框
- mongodb - 在 MongoDb 中使用查找和连接字符串进行聚合
- javascript - 在这种情况下如何调用输入?
- gmail-api - 有没有办法获取 Gmail 聊天收件人的详细信息?
- javascript - 反应本机相机不返回完整的文件路径