Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Get Year, Month, and Day from a Date Object</title> </head> <body> <script> let d = new Date(); // Extracting date part document.write(d.getDate() + "<br>"); // Display the day of the month document.write(d.getDay() + "<br>"); // Display the number of days into the week (0-6) document.write(d.getMonth() + "<br>"); // Display the number of months into the year (0-11) document.write(d.getFullYear()); // Display the full year (four digits) </script> </body> </html>