Xceedas

Xceedas
xceedas

Thursday, 11 September 2014

Add days to the current date using JavaScript

HTML Code :-
 
<body onload="onLoad()">
<button id="dateBtn">Click me!</button>
</body>
 
Javascript Code :- 
  1. function onLoad() {  
  2.     document.getElementById('dateBtn').onclick = function () {  
  3.         var dt = new Date();  
  4.         var NoOfDays = 10;  
  5.         dt.setDate(dt.getDate() + NoOfDays);  
  6.         alert(dt);  
  7.     };  
  8. }

No comments :