How to subtract days from Date in Javascript

<html>
<head>
 <script>
  var theDate = new Date();
  theDate.setDate(theDate.getDate()-42);
  document.getElementById('datediv').value = theDate;
 </script>
</head>
<body>
 Date 42days ago is
 <div id="datediv"></div>
</body>
</html>

Published by deeps blog

Programmer

Leave a comment

Design a site like this with WordPress.com
Get started