 <p>Try the following code.</p> <pre><code>function checkDate(theForm) { var a = theForm.date1.value; var b = theForm.date2.value; var date1 = new Date(a); var date2 = new Date(b); date1.setHours(date1.getHours() - 9); date2.setHours(date2.getHours() - 9); document.getElementById("demo").innerHTML = "Date 1 : " + date1.toString() + "&lt;br/&gt;Date 2 : " + date2.toString(); return false; } </code></pre>