// Create a new Date object
var currentDate = new Date();
// Get the year, month, and day
var year = currentDate.getFullYear();
var month = currentDate.getMonth() + 1; // add 1 to adjust for zero-based month index
var day = currentDate.getDate();
// Get the hour, minute, and second
var hour = currentDate.getHours();
var minute = currentDate.getMinutes();
var second = currentDate.getSeconds();
// Add leading zeros to single-digit values
month = month < 10 ? "0" + month : month;
day = day < 10 ? "0" + day : day;
hour = hour < 10 ? "0" + hour : hour;
minute = minute < 10 ? "0" + minute : minute;
second = second < 10 ? "0" + second : second;
// Create a string that represents the current date and time
var dateTimeString = year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;
// Log the date and time to the console
console.log(dateTimeString);