Check if a Date is specific day using JavaScript

 

Following is the code example to get day on of date using JavaScript 

const d1 = new Date();
if(d1.getDay() === 1){

	//monday
   
}elseif d1.getDay() === 2){

	//tuesday
   
}elseif d1.getDay() === 3){
   
	//wednesday

}elseif d1.getDay() === 4){
   
	//thursday

}elseif d1.getDay() === 5){

	//friday
   
}elseif d1.getDay() === 6){
   
	//saturday

}elseif d1.getDay() ===  0){

	//sunday
   
}

Tags:

Share:

Related posts