Is there a method using either JavaScript or jQuery to determine what day of the week it is? For instance, if the date a user picks in the box is a Sunday, I can alert them.
send date and you will get position of the same day of that month . i.e. 15/02/2018 is Third Thursday.
/*return day postion and dayname */
function weekAndDay(date) {
var arrayWeek =[];
var date = new Date(date),
days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],
prefixes = ['','First', 'Second', 'Third', 'Fourth', 'Fifth'];
if (date.getDate() % 7 == 0) {
var prefixes2 = date.getDate() / 7;
}else{
var prefixes2 = Math.ceil(date.getDate() / 7);
}
arrayWeek.push({
'dayPos' : prefixes[prefixes2] ,
'dayName' : days[date.getDay()]
});
return arrayWeek;
}