Get week day name from jquery ui calendar

后端 未结 5 2071
甜味超标
甜味超标 2020-12-21 14:36

I want to get the name of the Day when choosing date from jquery ui calender.

for example, when choosing 14-3-2012 it should returns Wednesday.

$(\"i         


        
5条回答
  •  -上瘾入骨i
    2020-12-21 14:49

    Create an array with the list of days in it ...

    var weekday=new Array(7);
    weekday[0]="Sunday";
    weekday[1]="Monday";
    weekday[2]="Tuesday";
    weekday[3]="Wednesday";
    weekday[4]="Thursday";
    weekday[5]="Friday";
    weekday[6]="Saturday";
    

    Then in your onselect function get the day number and use the above array to return the day of the week

    onSelect: function(dateText, inst) {
      var date = $(this).datepicker('getDate');
      var dayOfWeek = weekday[date.getUTCDay()];
      // dayOfWeek is then a string containing the day of the week
    
    }
    

提交回复
热议问题