
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
How do I get the current date in JavaScript?
To get the current date in JavaScript, use the getDate() method.
Example
You can try to run the following code get the date:
<!DOCTYPE html> <html> <body> <p>Today's Date</p> <button onclick="myFunction()">Get Date</button> <p id="test"></p> <script> function myFunction() { var date = new Date(); var n = date.getDate(); document.getElementById("test").innerHTML = n; } </script> </body> </html>
- Related Articles
- How do I get the current date and time in JavaScript?
- How can I get the current time and date in Kotlin?
- How to get current date and time in JavaScript?
- Get current date/time in seconds - JavaScript?
- How to get current date/time in seconds in JavaScript?
- How to get current date and time using JavaScript?
- How do I get the current time zone of MySQL?
- How do I display the current date and time in an iOS application?
- How do I display the current date and time in an Android application?
- How to get the current date in Java?
- How do I calculate the date six months from the current date using the datetime Python module?
- How do I get the creation date of a MySQL table?
- How do I get current URL in Selenium Webdriver 2 Python?
- How do I get the current AUTO_INCREMENT value for a table in MySQL?
- How do I subtract minutes from a date in JavaScript?

Advertisements