I am developing a system about Allowance in PHP, MySQL and it should calculate the last date employee to receive their allowance. This is my JavaScript to calculate the last date. Output for below code is 15-7-2015. I would like it to be 15-07-2015.
What should I change to get output like that ?
<script type="text/javascript">
function calculateLast() {
var x = document.form1.tempoh.value; //<-----------Tempoh Elaun
var CurrentDate = new Date();
CurrentDate.setMonth(CurrentDate.getMonth() + eval(x));
var day = CurrentDate.getDate();
var monthIndex = CurrentDate.getMonth()+1;
var year = CurrentDate.getFullYear();
document.getElementById('tamatElaun').value = day + "-" + monthIndex + "-" + year;
//document.write(day, monthNames[monthIndex], year);
}
</script>