Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Get year from user entered date in javascript

<html>
<head>
<title>Get year from user entered date</title>
</head>

<body>
	Enter Your Birth day: <input type="date" name="birthday" id="date">
	
	<button id="btn" onclick="getyear();">Get year</button>
	
	<script>
		function getyear()
		{
			var input=document.getElementById("date").value;
			var d = new Date(input);
			year = d.getFullYear();
			window.alert("Entered year is "+year);
			
		}
	</script>
</body>

</html>
 
PREVIOUS NEXT
Tagged: #Get #year #user #entered #date #javascript
ADD COMMENT
Topic
Name
5+3 =