JavaScript Get current year and month ,Date:- genius Student

  • The getDate() function return the current date.
  • The getMonth() function retun the current month.
  • The getFullYear() function return the current year.






Code


<!DOCTYPE html> 
<html> 

<head> 
 <meta name="viewport" content="width=device-width, initial-scale=1"> 
</head> 

<body> 
 <h1>Get Month Year and Day</h1> 

 <p>We can get separate the new Date()</p> 

 <input type="button" onclick="get_date();" value="Get Dates"> 

 <div id="d1"></div> 

 <script> 
  function get_date() 
  { 

   var today = new Date(); 

   var day = today.getDate(); 
   var month = today.getMonth() + 1; 
   var year = today.getFullYear(); 

   alert("Day : " + day); 
   alert("Month : " + month); 
   alert("Year : " + year); 

  } 
 </script> 

</body> 

</html>


Output







JavaScript Get current year and month ,Date:- genius Student JavaScript Get current year and month ,Date:- genius Student Reviewed by Network security on June 11, 2019 Rating: 5

No comments:

Useful Information

Powered by Blogger.