Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将jquery datepicker格式化为";2009年1月25日“;_Jquery_Format_Datepicker - Fatal编程技术网

如何将jquery datepicker格式化为";2009年1月25日“;

如何将jquery datepicker格式化为";2009年1月25日“;,jquery,format,datepicker,Jquery,Format,Datepicker,我本以为这是: .datepicker({ dateFormat: 'dd-mmm-yyyy' }); 对于月份,我得到了一些我不了解的数字,它们来自哪里?根据,一个M表示“月名短”,而“yy”表示“四位数年” 你想要: $('.selector').datepicker({ dateFormat: 'dd-M-yy' }); 看 日期格式字符串有些不标准: d-月日(无前导零) dd-月日(两位数) o-一年中的某一天(无前导零) oo-一年中的哪一天(三位数) D-日名缩写 DD-日期名

我本以为这是:

.datepicker({ dateFormat: 'dd-mmm-yyyy' });
对于月份,我得到了一些我不了解的数字,它们来自哪里?

根据,一个M表示“月名短”,而“yy”表示“四位数年”

你想要:

$('.selector').datepicker({ dateFormat: 'dd-M-yy' });

日期格式字符串有些不标准:

d
-月日(无前导零)
dd
-月日(两位数)
o
-一年中的某一天(无前导零)
oo
-一年中的哪一天(三位数)
D
-日名缩写
DD
-日期名称长度
m
-一年中的月份(无前导零)
mm
-一年中的月份(两位数)
M
-月名缩写
MM
-月名长度
y
-年份(两位数)
yy
-年份(四位数)
@
-Unix时间戳(自1970年1月1日起毫秒)
“…”
-文字
'
-单引号
还有别的吗-文字文本

在这种情况下,调查最有帮助的是:

*  d - day of month (no leading zero)
* dd - day of month (two digit)
* o - day of the year (no leading zeros)
* oo - day of the year (three digit)
* D - day name short
* DD - day name long
* m - month of year (no leading zero)
* mm - month of year (two digit)
* M - month name short
* MM - month name long
* y - year (two digit)
* yy - year (four digit)
* @ - Unix timestamp (ms since 01/01/1970)
* '...' - literal text
* '' - single quote
* anything else - literal text 

正确的方法是
dd-M-yy


或者,您可以使用自定义名称的选项。

如果您使用的是AUI Datepicker/Datepicketselect组件,则dateFormat的用法会有所不同

例如:如果您想显示2014年1月1日,您必须使用
dateFormat:“%d-%b-%Y”

以下是解释不同格式的文档:

我的工作代码:(在使用AUI的Liferay上)


AUI().use('AUI-datepicker',函数(A){
新A.DatePickerSelect(
{
附录顺序:['d','m','y'],
日历:{
日期格式:“%d-%b-%Y”
},
边界框:“#myDatepicker”,
触发器:“#myDateValue”
}
).render();
}
);

这是实现这一目标的一个很好的直接方法
*  d - day of month (no leading zero)
* dd - day of month (two digit)
* o - day of the year (no leading zeros)
* oo - day of the year (three digit)
* D - day name short
* DD - day name long
* m - month of year (no leading zero)
* mm - month of year (two digit)
* M - month name short
* MM - month name long
* y - year (two digit)
* yy - year (four digit)
* @ - Unix timestamp (ms since 01/01/1970)
* '...' - literal text
* '' - single quote
* anything else - literal text 
<div id="myDatepicker"></div>
  <input type="text" name="myDateValue" id="myDateValue" size="9" /> 

<aui:script>
  AUI().use('aui-datepicker', function(A) {
     new A.DatePickerSelect(
       {
         appendOrder: ['d', 'm', 'y'],
        calendar: {
        dateFormat: '%d-%b-%Y'
    },
    boundingBox: '#myDatepicker',
    trigger: '#myDateValue'
  }
).render();
}
);
</aui:script>