javascriptdate

How to determine if date is weekend in JavaScript


If I have a date coming into a function, how can I tell if it's a weekend day?


Solution

  • var dayOfWeek = yourDateObject.getDay();
    var isWeekend = (dayOfWeek === 6) || (dayOfWeek  === 0); // 6 = Saturday, 0 = Sunday