title: Writing a code / query that runs after midnight using javascript
body: <p>I just wanted to ask a simple question about MongoDB and javascript (express js).</p>
  <p>Here are my requirements:</p>
  <p>I am trying to create a back-end service for films and series. I created most of the basic routes and functions. I want to pick a film from the database for the &quot;Movie Of The Day&quot; subtitle.</p>
  <p>My Function:</p>
  <pre><code>function filterFilmsForImbd(films,imbd){
      let filmChances = [];
      films.filter(film=&gt;{
          if(film.imbdScore &gt;= imbd){
              filmChances.push(film);
          };
      });
      return filmChances;
  };
  
  //Movie Of The Day
  function movieOfTheDay(films) {
      const date = new Date();
      if (date.getHours() &gt;= 0) {
          let arr = filterFilmsForImbd(films,7)
          let numberOfFilmChances = arr.length;
          let randomFilmPicker = Math.floor(Math.random() * numberOfFilmChances);
          return arr[randomFilmPicker]//returns object (film object)
      };
  };
  
  //Recommended Films
  function recommendedMovies(films){
     return  filterFilmsForImbd(films,5);
  };
  </code></pre>
  <p>I wrote a function that can run after midnight (00:00) but when I refresh the page it keeps continue to get random data.</p>
  <p>How can I create a function that can pick a movie randomly just once a day?</p>
  <p>Do you want me to extend my question with my routes? Let me know.</p>