I'm looking for some help to write some conditional logic for an ad compagin. There are 5 conditions that need to be addressed:
If the date is prior to April 10, 2023
If the date is date is at least April 10th (a week away)
If the date is absolutely April 16th
- If the date is after April 16th, and it IS SUNDAY
If the date is after April 16th, and it's NOT SUNDAY - DEFAULT
I think I have 1,2,3 and 5 addressed, but the 4th condition is outside my wheelhouse. Any help would be greatly appreciated.
Here's my code so far:
hypeDocument.getElementById('DateTxt-01').style.display = "none";
hypeDocument.getElementById('DateTxt-02').style.display = "none";
hypeDocument.getElementById('DateTxt-03').style.display = "none";
hypeDocument.getElementById('DateTxt-04').style.display = "none";
hypeDocument.getElementById('DateTxt-05').style.display = "none";
var d = new Date();
var year = d.getFullYear();
var month = d.getMonth() + 1;
var day = d.getDate();
if (day <= 9 && month <= 4 && year == 2023 ) {
hypeDocument.getElementById('DateTxt-01').style.display = "block";
} else if (day <= 15 && month <= 4 && year == 2023 ) {
hypeDocument.getElementById('DateTxt-02').style.display = "block";
} else if (day == 16 && month == 4 && year == 2023 ) {
hypeDocument.getElementById('DateTxt-03').style.display = "block";
// } else if (day == ANY SUNDAY AFTER THE 16th && month >= 4 && year == 2023 ) {
// hypeDocument.getElementById('DateTxt-04').style.display = "block";
} else {
hypeDocument.getElementById('DateTxt-05').style.display = "block";
}