Now, let’s determine the deadline. If the current day of the month is on or after the 20th, we will set the countdown to the 20th of the next month. Otherwise, it will count down to the 20th of the current month:
let date = new Date();
let count;
if (date.getDate() >= 20) {
count = date.getMonth() + 2; // Move to the next month
} else {
count = date.getMonth() + 1; // Use the current month
}
let year = date.getFullYear(); // Get the current year
let date_str = `${year}-${count.toString().padStart(2, '0')}-20T23:59:59`; // Format the deadline as YYYY-MM-20
let deadline = new Date(date_str);