Created
January 3, 2022 05:24
-
-
Save Attaulla9/b4319fbd5488a9e85d1a9d87250caa3d to your computer and use it in GitHub Desktop.
Date range between days
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let isWeekend = new Date(); | |
const months = ["Jan", "Feb", "Mar", "Apr", "May", "June", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] | |
console.log(isWeekend.getDay()) | |
if (isWeekend.getDay() == 6 || isWeekend.getDay() == 0) { | |
let todayIsWeekendStart = new Date(); | |
todayIsWeekendStart.setDate(todayIsWeekendStart.getDate() + (((1 + 7 - todayIsWeekendStart.getDay()) % 7) || 7) + 7); | |
let weekend_Start = todayIsWeekendStart.getDate() + " " + (months[todayIsWeekendStart.getMonth()]) + " " + todayIsWeekendStart.getFullYear(); | |
let todayIsWeekendEnd = new Date(); | |
todayIsWeekendEnd.setDate(todayIsWeekendStart.getDate() + 6); | |
let weekend_End = todayIsWeekendEnd.getDate() + " " + (months[todayIsWeekendEnd.getMonth()]) + " " + todayIsWeekendEnd.getFullYear(); | |
console.log(weekend_Start + " - " + weekend_End) | |
document.getElementsByClassName("date_of_webinar")[0].textContent = weekend_Start + " - " + weekend_End; | |
//$(".date_of_webinar").text(weekend_Start + " - " + weekend_End); | |
} else { | |
var StartDate = new Date(); | |
StartDate.setDate(StartDate.getDate() + (((1 + 7 - StartDate.getDay()) % 7) || 7)); | |
let Start = StartDate.getDate() + " " + (months[StartDate.getMonth()]) + " " + StartDate.getFullYear(); | |
var EndDate = new Date(); | |
EndDate.setDate(StartDate.getDate() + 6) | |
let End = EndDate.getDate() + " " + (months[EndDate.getMonth()]) + " " + EndDate.getFullYear() | |
console.log(Start + " -- " + End) | |
//$(".date_of_webinar").text(Start + " - " + end); | |
document.getElementsByClassName("date_of_webinar")[0].textContent = Start + " - " + End; | |
// (".date_of_webinar").text("9 Jan 2022-16 Jan 2022"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment