使用datejs插件根据区域设置日期格式

| 我正在使用datejs库,并且日期格式有问题。 我需要在没有小时的情况下将今天的日期打印到屏幕上。 当我运行这一行:
Date.today().toString(\'d\')
我正在获取日期的日期部分(即15)。 如果您查看文档,他们会指定在文化中使用\ d作为标准日期-这正是我想要的。 http://code.google.com/p/datejs/wiki/FormatSpecifiers 如果我正在使用,我希望它能打印mm / dd / yyyy
<script type=\"text/javascript\" src=\"/scripts/date.js\"></script>
如果我正在使用en-GB
<script type=\"text/javascript\" src=\"/scripts/date-en-GB.js\"></script>
打印dd / mm / yyyy 我知道我可以在tostring()中指定formatstring或类似这样的内容:
(Date.today().toString(Date.CultureInfo.formatPatterns.shortDate)
但是我更喜欢使用d选项。 谢谢你的帮助, 皮尼     
已邀请:
这里有几个问题: 1)Wiki文档与http://code.google.com/p/datejs/主页上的文档不同,在于主页将您要作为自定义说明符而不是标准说明符的说明符。 Wiki上的文档似乎建议使用多个字符应触发自定义模式,但这不会如您所指出的那样发生。我没有看到报告此错误的任何错误,所以也许您想自己这样做并得到通知的通知:http://code.google.com/p/datejs/issues/list 2)您应该可以执行
Date.today().toShortDateString();
,但此处似乎有一个bug(在所有区域性文件中)。来源列出:
Date.prototype.toShortDateString=function(){
    return this.toString(Date.CultureInfo.formatPatterns.shortDatePattern);
};
...,但格式模式应为Date.CultureInfo.formatPatterns.shortDate(或模式应以不同的方式定义或使用同义词)。请参阅http://code.google.com/p/datejs/issues/detail?id=116。 3)我发现唯一可以使用其缩写字母支持“ custom”说明符的地方是通过包含test / scripts / date-functions.js文件。
<script type=\"text/javascript\" src=\"build/date-en-US.js\"></script>
<script type=\"text/javascript\" src=\"test/scripts/date-functions.js\"></script>
<script>
alert(Date.today().dateFormat(\'d\'));
</script>
如果您报告此问题,则可能会提出此问题,因为似乎仅包含\ test \文件夹中的文件来获取所需的功能并不可靠。     

要回复问题请先登录注册