如何格式化jQueryUI datepicker日历的年份?

时间:2011-06-24 02:36:59

标签: javascript calendar format jquery-ui-datepicker

我可以通过monthNames选项格式化日历顶部的月份 但我不知道如何格式化年份
我想在下面的演示日历中将“2011年6月”转换为“June 2011y” http://jqueryui.com/demos/datepicker/

3 个答案:

答案 0 :(得分:0)

JSFiddle Example

jQueryUI documentation

  • 使用指定的yearSuffix选项初始化一个datepicker:

    $( ".selector" ).datepicker({ yearSuffix: 'CE' });
    
  • 在init:

    之后获取或设置yearSuffix选项
    //getter
    var yearSuffix = $( ".selector" ).datepicker( "option", "yearSuffix" );
    
    //setter
    $( ".selector" ).datepicker( "option", "yearSuffix", 'CE' );
    

答案 1 :(得分:0)

http://docs.jquery.com/UI/Datepicker/formatDate

代码示例

Initialize a datepicker with the dateFormat option specified.
$( ".selector" ).datepicker({ dateFormat: 'yy-mm-dd' });
Get or set the dateFormat option, after init.
//getter
var dateFormat = $( ".selector" ).datepicker( "option", "dateFormat" );
//setter
$( ".selector" ).datepicker( "option", "dateFormat", 'yy-mm-dd' );

答案 2 :(得分:0)

$("#datepicker").datepicker({
    numberOfMonths: 2,
    showMonthAfterYear: true,
    yearSuffix: "Year", //this is what you are looking for
}

});