JSFiddle - React, Tailwind, and code Playground

by omartheman949

HTML

<a id="premiere-link" href="#">Youtube Link</a>

  <script>
    // setInterval(canOpen, 1000);
    let month, day, year, time;
    const link = document.getElementById('premiere-link');
    setDate(); //set date immediatly on page load
    setInterval(setDate, 1000); //update date every second
    function setDate() {
      var dateObj = new Date();
      month = dateObj.getUTCMonth() + 1; //months from 1-12
      day = dateObj.getUTCDate();
      year = dateObj.getUTCFullYear();
      time = dateObj.getTime();
    }
    function canOpen(month, day){
      //set month and day for release
      if (month >= 11 && day >= 1) {
        console.log('if')
        alert('You just got RickRolled')
        link.setAttribute('href', 'https://www.youtube.com/watch?v=dQw4w9WgXcQ');
        link.setAttribute('target', '_blank');
      } else {
        console.log(month, day);
        console.log('else')
        link.setAttribute('href', '#');
        alert('You have to wait to get RickRolled')
      }
    }
    link.onclick = () => {canOpen(month, day)};
  </script>