title: Comparing a current timestamp date in JSP with dates from a database
body: <p>Hi I have got a JSP page which displays the current date and time to the user after they have logged in, my jsp code is:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
          /25893-javascript-current-date-and-time-.html
          var todayDate=new Date();
          var date=todayDate.getDate();
          var month=todayDate.getMonth()+1;
          var year=todayDate.getFullYear();
          var hours=todayDate.getHours();
          var minutes=todayDate.getMinutes();
          var seconds=todayDate.getSeconds();
          document.writeln("You have logged in at: "+ hours + " : " + minutes + " : " + seconds);
          document.writeln("on: " + date + "/" + month + "/" + year);
      &lt;/script&gt;
  </code></pre>
  
  <p>I want to compare the current date and time that the user has logged in with the date and time from a database (In the database I already have a field called startDateTime with the DATETIME datatype) and display the row from the database to the user (I already have a couple of date fields in the database). Does anyone know what's the easiest way of doing this?</p>