logo

dayOfWeek (Javascript)

JavaScript: The Definitive Guide
Subject: dayOfWeek

Overview: The dayOfWeek uses the local machines clock to determine a numeric value of the current day. The week is zero based starting with Sunday being zero.

function dayOfWeek()
{
	var stDate;
	var now;
	var assoc= new Array(7);

	assoc[0]="Sunday";
	assoc[1]="Monday";
	assoc[2]="Tuesday";
	assoc[3]="Wednesday";
	assoc[4]="Thursday";
	assoc[5]="Friday";
	assoc[6]="Saturday";

	now= new Date();
	stDate=now.getDay();
	return(assoc[stDate]);
}
s