Search code examples
javascriptcalendarformatjquery-ui-datepicker

How to format year of jQueryUI datepicker calendar?


I can format month which is on the top of calendar by monthNames option.
But I don't know how to format year.

I want to covert "June 2011" in the following demo calendar to like "June 2011y".
http://jqueryui.com/demos/datepicker/


Solution

  • JSFiddle Example

    In the jQueryUI documentation:

    • Initialize a datepicker with the yearSuffix option specified:

      $( ".selector" ).datepicker({ yearSuffix: 'CE' });
      
    • Get or set the yearSuffix option, after init:

      //getter
      var yearSuffix = $( ".selector" ).datepicker( "option", "yearSuffix" );
      
      //setter
      $( ".selector" ).datepicker( "option", "yearSuffix", 'CE' );