0

次のコードを使用して、私のサイトでjQuery.calendarPickerを使用しようとしています。

<script type="text/javascript">
var calendarPicker2 = $("#wedding_date_picker").calendarPicker({
  showDayArrows: false,
  callback:function(cal) {
    console.log(cal.currentDate);
  }
});
</script>

私はなんとか機能し、次の行に沿って何かをログに記録しています:

Date {Wed Aug 21 2013 16:12:19 GMT+0100 (GMT Daylight Time)}

ただし、今やりたいのは、この日付を取得して、yyyy-mm-dd にフォーマットした後、非表示の入力フィールドに挿入することです...問題は、フォーマットの方法がわからないことです。

誰か助けてくれませんか?ありがとうございました :)

4

2 に答える 2

0

Date.format次のようにJS 関数を使用できます。

var formattedDate = cal.currentDate.format("yyyy-mm-dd");
于 2012-08-21T15:20:34.033 に答える
0

jquery UI マニュアルから:

//setter
$( ".selector" ).datepicker( "option", "dateFormat", "yy-mm-dd" );

http://jqueryui.com/demos/datepicker/#option-dateFormat

利用可能な日付形式の完全なリストは、 http ://docs.jquery.com/UI/Datepicker/formatDate にあります。

于 2012-08-21T15:22:26.883 に答える