Check if weekend exist in date range using javascript

前端 未结 7 1897
我在风中等你
我在风中等你 2021-01-12 21:27

Wondering if anyone has a solution for checking if a weekend exist between two dates and its range.

var date1 = \'Apr 10, 2014\';
var date2 = \'Apr 14, 2014\         


        
7条回答
  •  忘掉有多难
    2021-01-12 21:46

    Use Date.getDay() to tell if it is a weekend.

      if(tempDate.getDay()==6 || tempDate.getDay()==0)
    

    Check this working sample:

    http://jsfiddle.net/danyu/EKP6H/2/

    This will list out all weekends in date span. Modify it to adapt to requirements. Good luck.

提交回复
热议问题