Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript date

<!DOCTYPE html>
<html>
  
<head>
    <title>How to get current date in JavaScript?</title>
</head>
  
<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1> 
    <b>How to get current date in JavaScript?</b>
      
<p> Current Date is: <span class="output"></span></p>
  
    <button onclick="getCurrentDate()">Get current Date</button>
      
    <script type="text/javascript">
    function getCurrentDate() {
        let date = new Date().toDateString();
        document.querySelector('.output').textContent = date;
    }
    </script>
</body>
  
</html>
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #javascript #date
ADD COMMENT
Topic
Name
1+4 =