<script> var mydate = new Date("07/31/2017"); var date = new Date(); date.setHours(0, 0, 0); var n = Math.round((date - mydate) / 864E5) document.write("n = " + n) </script>