Click here to Skip to main content
15,890,043 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want current date (start date) to pick automatically and validation date(end date) is displayed for 2 year and it should display the remaining days in validation column

What I have tried:

HTML
<!DOCTYPE html>

Try it
HTML
<p id="demo"></p>
function myFunction() {
    var currentDate = new Date();
    var Year = currentDate.getFullYear();
    var day = currentDate.getDate();
    var month = currentDate.getMonth();
    var newYear=new Date(Year+1,month,day)
    document.getElementById("demo").innerHTML = newYear;
}
Posted
Updated 11-Jan-17 0:05am
v5
Comments
Member 12944301 11-Jan-17 1:28am    
plz help me out
Suvendu Shekhar Giri 11-Jan-17 1:39am    
Not clear. The question asked and the code shared doesn't resemble. Please explain a bit more about your exact requirement.
Member 12944301 11-Jan-17 3:14am    
the above code is printing today's date but i want validity also to print with that.
Member 12944301 11-Jan-17 3:14am    
am working on progress report project. i want today's date to pick automatically for registration column and validation for 2 year how to print that in javascript.
Peter Leow 11-Jan-17 1:54am    
What do you means" current date (start date) to pick automatically". who pick the current date?

1 solution

Whatever it is, once you learn of how date time derived in JavaScript from How to add hour and minute in javascript[^], the solution is just some arithmetical calculations away.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900