title: The timer returns the Nan value for the hour after the screen is reloaded
body: <p>I made a timer and using Local Storage I wanted to save it in memory until the timer is reloaded. When I specify the time in the Date input, the numbers are displayed correctly. But as soon as the amount of Nan is loaded, it is set to hour.
  please help me to find the problem thanks.
  <strong>html &amp; css code:</strong></p>
  <pre><code>&lt;html lang=&quot;en&quot;&gt;
  
  &lt;head&gt;
      &lt;meta charset=&quot;UTF-8&quot;&gt;
      &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt;
      &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
      &lt;title&gt;Document&lt;/title&gt;
  &lt;/head&gt;
  &lt;style&gt;
          .clock{
              background-color: blue;
              width: 400px;
              text-align: center;
              font-size: 1em;
              color: white;
          }
          .clock &gt; span{
              padding: 10px;
              border-radius: 10px;
              background-color: black;
          }
          .clock &gt; span &gt; span{
              padding: 5px;
              border-radius: 10px;
              background-color: red;
              margin-right: 2px;
          }
          input{
              padding: 15px;
              margin: 20px;
              font-size: 1.5em;
          }
  &lt;/style&gt;
  
  &lt;body&gt;
  
      &lt;div&gt;
  
          &lt;input type=&quot;date&quot; name=&quot;endDate&quot;&gt;
          &lt;div class=&quot;clock&quot;&gt;
              &lt;span&gt;&lt;span class=&quot;days&quot;&gt;0&lt;/span&gt;day&lt;/span&gt;
              &lt;span&gt;&lt;span class=&quot;hours&quot;&gt;0&lt;/span&gt;Hours&lt;/span&gt;
              &lt;span&gt;&lt;span class=&quot;minutes&quot;&gt;0&lt;/span&gt;Minute&lt;/span&gt;
              &lt;span&gt;&lt;span class=&quot;seconds&quot;&gt;0&lt;/span&gt;second&lt;/span&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  <p><strong>script code:</strong></p>
  <pre><code>&lt;Script&gt;
          const endDate = document.querySelector(&quot;input[name='endDate']&quot;);
          const clock = document.querySelector(&quot;.clock&quot;);
          var timestop = false;
          var timeInterval;
          const savevalue = localStorage.getItem(&quot;counterdown&quot;) || false;
          if (savevalue) {
              startclock(savevalue);
              let inputValue = new Date(savevalue);
              endDate.valueAsDate = inputValue;
              console.log(savevalue);
          }
          endDate.addEventListener(&quot;change&quot;, function (e) {
              e.preventDefault();
              clearInterval(timeInterval);
              const temp = new Date(endDate.value);
              localStorage.setItem(&quot;counterdown&quot;, temp);
              startclock(temp);
              timestop = false;
          })
          function startclock(t) {
              function updates() {
                  var tl = (time(t));
                  if (tl.Total &lt; 0) {
                      timestop = true;
                  }
                  for (var pro in tl) {
                      var elmn = clock.querySelector(&quot;.&quot; + pro);
                      if (elmn) {
                          elmn.innerHTML = tl[pro];
                      }
                  }
              }
              updates();
              if (!timestop) {
                  timeInterval = setInterval(updates, 1000);
              }
              else {
                  clearInterval(timeInterval);
              }
          }
          function time(t) {
              var currenttime = new Date();
              var Total = Date.parse(t) - Date.parse(currenttime);
              var seconds = Math.floor((Total / 1000) % 60);
              var minutes = Math.floor(((Total / 1000) / 60) % 60);
              var hours = Math.floor((t / (1000 * 60 * 60)) % 24);
              var days = Math.floor(Total / (1000 * 60 * 60 * 24));
              return {
                  &quot;total&quot;: Total,
                  &quot;days&quot;: days,
                  &quot;hours&quot;: hours,
                  &quot;minutes&quot;: minutes,
                  &quot;seconds&quot;: seconds
              };
  
          }
      &lt;/Script&gt;
  </code></pre>