2011-06-24 9 views
0

monthNamesオプションでカレンダーの先頭にある月を書式設定できます。
しかし、私は年をどのようにフォーマットするのか分かりません。

「2011年6月」のように、次のデモカレンダーで「2011年6月」を隠したいと思っています。 jQueryUI documentation
http://jqueryui.com/demos/datepicker/

jQueryUI datepickerカレンダーの年をフォーマットする方法は?

+0

'2011y'は何ですか? – vol7ron

+0

は2011年6月26日に「2011nen 6gatsu 26nichi」と呼ばれています。 nen、gatsu、nichiは実際にアルファベットではなく漢字です。 意味は年、月、日です。2011yのyは年を意味します。 私はここで人々が日本語を知らないと思ったので "y"を使用します。 –

+0

私は誰にでも話すことができませんが、日本語はわかりません。私は、4桁で月/日は決して4桁にならないので、何も必要ないと思います。私は '11nen'のように簡略化のために使われていることがわかりました – vol7ron

答えて

0

JSFiddle Example

  • 指定yearSuffixオプションで日付ピッカーを初期化します。

    $(".selector").datepicker({ yearSuffix: 'CE' }); 
    
  • を取得またはyearSuffixオプションは、initの後に、設定:

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

ありがとうございました。それはまさに私が知りたいものです。私は文書のオプションを見落とした。 –

+0

probがない、簡単に行うことができます。ただし、プレフィックスを追加する場合や、実際に何年かの変更を行う場合は、Davidが提案したようにdateformatを使用するか、コールバックを使用して生成された文字列を変更する必要があります。 – vol7ron

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'); 
0
$("#datepicker").datepicker({ 
    numberOfMonths: 2, 
    showMonthAfterYear: true, 
    yearSuffix: "Year", //this is what you are looking for 
} 

}); 
関連する問題