我正在使用具有本地化和全球化的 ASP.NET 应用程序.在给定用户环境的情况下,我很难理解如何让 JavaScript 中的 Date() 函数正常工作.我的用户群分布在墨西哥(西班牙语)和美国(英语)之间.由于墨西哥日期格式是 dd/mm/yyyy 而英文格式是 mm/dd/yyyy,标准 Date(strDate) javascript 构造函数对我不起作用.
I'm working with an ASP.NET app with localization and globalization. I'm having some difficulty understanding how to get the Date() function in javascript to work properly given the user's environment. My user base is split between Mexico (spanish) and the US (english). Since the Mexico date format is dd/mm/yyyy and the english format is mm/dd/yyyy, the standard Date(strDate) javascript constructor does not work for me.
有谁知道处理 javascript 日期值的全球化/本地化的最佳方法?我有一些业务规则要强制执行,例如 dateA 必须比 dateB 早 90 天,并且 dateB 不能超过今天.
Does anyone know the best way to handle globalization/localization of a javascript Date value? I have some business rules to enforce like dateA must be 90 days prior to dateB and dateB cannot exceed today.
看看datejs,它可以很好地处理本地化.它带有很多全球化设置.您只需加载当前 CultureInfo 的全球化设置,而 datejs 会负责其余的工作.
Take a look at datejs, it handles localization very nicely. It comes with a lot of globalization setups. You just load the globalization setup of your current CultureInfo and datejs takes care of the rest.
这篇关于Javascript 日期本地化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!