• Coding
  • PHP date calculation and addition

using Html / PHP :
i have two textbox i want to insert date in the first textbox and when inserting the date the second textbox will be filled automatically with the date of the first textbox + 10 years.

Example :

Start Date: 01/01/2014 (When filling here)

automatically ---->End Date: 01/01/2024

Sorry guys but im new to php and html... i work in a small company and im trying to create a small application but i have this small problem. thanks in advance.
See if this peace of Code Helps You and Good Luck With your Application
<!DOCTYPE html>
<html>
<head>
<script>
function myFunction()
{
var x=document.getElementById("fname");
var y=document.getElementById("fname2");


var d = new Date(x.value);

y.value=((d.getMonth()+1)+"-"+d.getDate()  + "-" +(d.getFullYear()+10));

}
</script>
</head>
<body>

<input type="date" id="fname" onchange="myFunction()">
<input type="text" id="fname2" disabled>


</body>
</html>
You don't need PHP to do that, you can use JavaScript. This is a nice JS library that handles dates and times: momentjs.com
Thanks Guys! I Really appreciate it !