jQuery ui datepicker, get Day of week from onSelect

前端 未结 3 888
感情败类
感情败类 2020-12-31 13:14

Is it possible to get the day of the week from the onSelect event of the datepicker.

I know I can get the day of the month, but I want the day of the week. Even jus

3条回答
  •  情话喂你
    2020-12-31 14:02

    This should do the trick:

    function(event, ui) {
        var date = $(this).datepicker('getDate');
        var dayOfWeek = date.getUTCDay();
    };
    

    This has the advantage of not needing to parse whatever arbitrary date format you've chosen for the Datepicker's text field - the getDate method returns a native Javascript Date object which you can then easily extract the date fields you need.

提交回复
热议问题