Hi,
Just as the title says, any ideas?
Malcolm
EDIT: Oh, can you you supply code to do it please?
Hi,
Just as the title says, any ideas?
Malcolm
EDIT: Oh, can you you supply code to do it please?
Yes, it is possible, we can write a JavaScript code for that using JavaScript Date object.
Please use following JavaScript code.
var d = new Date()
document.write(d.getDay())
The Date class offers the getDay() Method that retrieves the day of the week component of the date as a number from 0 to 6 (0=Sunday, 1=Monday, etc)
var date = new Date();
switch(date.getDay()){
case 0: alert("sunday!"); break;
case 6: alert("saturday!"); break;
default: alert("any other week day");
}
Sure it is! The Date
class has a function called getDay()
which returns a integer between 0 and 6 (0 being Sunday, 6 being Saturday). So, in order to see if today is during the weekend:
var today = new Date();
if(today.getDay() == 6 || today.getDay() == 0) alert('Weekend!');
In order to see if an arbitrary date is a weekend day, you can use the following:
var myDate = new Date();
myDate.setFullYear(2009);
myDate.setMonth(7);
myDate.setDate(25);
if(myDate.getDay() == 6 || myDate.getDay() == 0) alert('Weekend!');