Created
November 7, 2019 03:21
-
-
Save Danushka96/21bd4a24272a5361f466b0a6ee7d0669 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
</head> | |
<body> | |
<input type="date" id="inDate"><br><br> | |
<input type="text" id="outDate"> | |
<div id="output"></div> | |
<script type="text/javascript"> | |
Date.prototype.addDays = function(d) { | |
this.setDate(this.getDate() + d); | |
return this; | |
}; | |
var inputDate = document.getElementById('inDate'); | |
var outDate = document.getElementById('outDate'); | |
var inDateValue = inputDate.value; | |
inputDate.onchange = function(event) { | |
var d = new Date(this.value) | |
var dd = d.getDate(); | |
var mm = d.getMonth() + 2; //January is 0! | |
var yyyy = d.getFullYear(); | |
// var newDate = yyyy + '-' + mm + '-' + dd; | |
var newDate = dd + '/' + mm + '/' + yyyy; | |
outDate.value = newDate; | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment