title: Javascript Time Comparison: What is the best way to achieve this?
body: <p>Here I have a function which I use to calculate the difference between two Time variables, <code>start</code> and <code>end</code>, and display the output as 'Past', 'Current', or 'Future'.</p>
  
  <p>I was able to calculate 'Current' and 'Future' values, but no luck with "Past'. Here is the <a href="http://jsfiddle.net/9jk6a/8/" rel="nofollow">jsFiddle</a> and any help would be great.   </p>
  
  <p>On a side note, I do prefer a plugin-less way to achieve this.      </p>
  
  <pre><code>//My Start time and End time
  var start = "Mon Nov 22 2012 08:45:00 GMT+0800 (Malay Peninsula Standard Time)";
  var end = "Mon Nov 22 2012 10:15:00 GMT+0800 (Malay Peninsula Standard Time)";
  
  //Calling to test function
  test(start, end);
  
  //Function to calculate 
  function test(startTime, endTime) {
      startTime= new Date(startTime);
      endTime= new Date(endTime);
      var currentTime = new Date();
      var difference = currentTime - startTime; 
  
      if (difference &gt; 0 &amp;&amp; currentTime &gt; startTime) {
          alert ("Past!");
      } 
  
      if(startTime &lt; currentTime &amp;&amp; currentTime &lt; endTime){ 
          alert("Current!");
      }
  
      if(difference &lt; -1){
          alert("Future!");
      }
  }​
  </code></pre>
  
  <p>Link to <strong><a href="http://jsfiddle.net/9jk6a/8/" rel="nofollow">jsFiddle</a></strong></p>