title: javascript - compare current time/date to range
body: <p>I am looking to make a function that would basically compare the current date time to a list.  For instance from 8/22/13 at 0700 until 8/29 at 0700 it would return "Joe Mama - phone number 555-5555" then from 8/29 at 0700 until 9/5/13 at "0500" it would return "Angie Daddy - phone number 555-5555".  It is for an "on-call" schedule.</p>
  
  <p>The best I was able to do was get the date and do a == check which takes waaay too long and only changes at midnight.  If I wanted to do it down to the hour I would have to write 168 if/then statements a week (one for each hour in the week).</p>
  
  <p>Anyone think they could point me in the right direction?  Certainly not looking for someone to write the code, I just don't know what other terms to search for.  </p>
  
  <p>EDIT (too new, it won't let me answer):</p>
  
  <p>Thank you very much to ergwin for the help!  For anyone looking for something like this, here's how to do it easiest (not best, but it works).  Convert the times to Epoch time (wikipedia it if you're unfamiliar).  While it is a little bit of a pain to do the conversions, the comparisons are much simpler.</p>
  
  <p>The site I linked in the notes for my page (so I don't lose it), converts times and dates to Epoch time, but forwhatever reason I had to add three zeros to the end of the time it gave me.</p>
  
  <p>Hope that made sense!
  Sources:</p>
  
  <p><a href="http://www.epochconverter.com/" rel="nofollow">http://www.epochconverter.com/</a>
  <a href="http://www.w3schools.com/jsref/jsref_gettime.asp" rel="nofollow">http://www.w3schools.com/jsref/jsref_gettime.asp</a></p>
  
  <pre><code>&lt;HTML&gt;
  &lt;script type="text/javascript"&gt;
  
  var d = new Date();
  var n = d.getTime(); 
  
  document.write(n)
  
  
  if (n &gt;=  1376913600000 &amp;&amp; n &lt;= 1377518400000)
   {
  document.write("Joe Momma");
  document.write(full)
  }
  if (n &gt;=  1377518400000 &amp;&amp; n &lt;= 1378123200000)
   {
  document.write("Angie Daddy");
  document.write(full)
   }
  
  
  
  &lt;/script&gt;
  &lt;/html&gt;
  </code></pre>