title: HTML5 application for smarthphone(android, ios) with localStorage date()
body: <p>FOR THE MODERATORS!!
  I CREATED THIS QUESTION ON stackapps AFTER A RESEARCH INTO THE STACK SECTIONS.
  DO I NEED TO DELETE THIS ONE?</p>
  
  <p>Hi I'm creating a simple HTML5 app which uses a timeout().
  The basic function of the APP is:
  you select an Item and a timeout() starts. It works properly but if I close the application the timer will stop of course.
  I'm trying to store it in localStorage but it does not work for what I need.</p>
  
  <p>here is my code</p>
  
  <p>get current date</p>
  
  <pre><code>var current = new Date();
  </code></pre>
  
  <p>check if localStorage is empty or not. If not, it calculate the difference in milliseconds beetwen the stored date and the current date.</p>
  
  <pre><code>function update() {
    if (localStorage.time != undefined){
    var diff = current - localStorage.time;
     alert (diff)
  }
  
  update();
  </code></pre>
  
  <p>here the function save for the date to be stored and it check the difference beetwen the two dates.</p>
  
  <pre><code>function save() {
    localStorage.time = new Date();
    click_time = localStorage.time;
    var diff =  click_time - current;
     alert (diff);
     }
  </code></pre>
  
  <p>clear the localStorage</p>
  
  <pre><code>   function clear() {
     localStorage.clear();
     }
  
  $(document).ready(function() {
  $('input#save').click(function(){
    save();
  });
  $('input#clear').click(function(){
    clear();
  });
  });
  
  
  &lt;input type="submit" value="click me!" id="save"/&gt;
  &lt;input type="submit" value="clear" id="clear"/&gt;
  </code></pre>
  
  <p>But I just get NaN!!The problem is how do i need to store the date in the localStorage and how can i get it as a date?</p>
  
  <p>Thanks in advance.</p>