从 jquery ui 日历中获取工作日名称 [英] Get week day name from jquery ui calendar
本文介绍了从 jquery ui 日历中获取工作日名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从 jquery ui 日历中选择日期时获取日期的名称.
I want to get the name of the Day when choosing date from jquery ui calender.
例如,在选择14-3-2012时,它应该返回星期三.
for example, when choosing 14-3-2012 it should returns Wednesday.
$("input[name=date]").datepicker({
dateFormat: 'yy-mm-dd',
changeYear:true,
changeMonth:true,
onSelect: function(dateText, inst) {
var date = $(this).datepicker('getDate');
//what should I write here to get the day name?
}
});
推荐答案
创建一个包含天数列表的数组 ...
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";
然后在您的 onselect 函数中获取日期编号并使用上述数组返回星期几
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
}
这篇关于从 jquery ui 日历中获取工作日名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文