Determine if a date is a Saturday or a Sunday using JavaScript -


Is it possible to determine whether a date is using javascript Saturday or Sunday?

Do you have code for this?

Sure it is! There is a function in the class which gives an integer between 0 and 6 (Sunday, 6 Saturdays). So, to see what is today during the weekend:

  var today = new date (); If (today.getDay () == 6 || Today .getDay () == 0) Alert ('Weekend!');  

To see if there is an arbitrary date weekend, 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!');  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -