Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to determine if date is weekend in javascript [closed]

if i have a date coming into a function, how can i tell if its a weekend day?

like image 607
leora Avatar asked Aug 23 '10 21:08

leora


People also ask

How do you calculate working days in JavaScript excluding weekends and holidays?

Date. workingDaysFrom(fromDate) calculates the number of working days between 2 Date objects (excluding weekends; Sat and Sun). The method will return “-1” if the fromDate is an invalid Date object or is later than the compared Date.

Is the JavaScript date object always one day off?

@Codo - yes, good reply. ECMA-262 15.9. 1.15 applies. The OP should use "2011-09-24T20:00:00-04:00" or similar.

How do I get this week in JavaScript?

var today = new Date(); var startDay = 0; var weekStart = new Date(today. getDate() - (7 + today. getDay() - startDay) % 7); var weekEnd = new Date(today. getDate() + (7 - today.


1 Answers

var dayOfWeek = yourDateObject.getDay(); var isWeekend = (dayOfWeek === 6) || (dayOfWeek  === 0); // 6 = Saturday, 0 = Sunday 
like image 125
LukeH Avatar answered Oct 19 '22 17:10

LukeH